P4APIExceptions.cs #1

  • //
  • guest/
  • erik_purins/
  • P4.Net/
  • release/
  • 0.9/
  • src/
  • P4API/
  • Exceptions/
  • P4APIExceptions.cs
  • View
  • Commits
  • Open Download .zip Download (6 KB)
using System;
using System.Text;

namespace P4API.Exceptions
{
    /// <summary>
    /// Base exception for P4API.
    /// </summary>
    public class P4APIExceptions : System.Exception 
    {
        internal P4APIExceptions(){}
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Generic P4API exception!";
            }
        }
    }
    /// <summary>
    /// Exception: Attempting to run a command while the Perforce Server is not connected!
    /// </summary>
    public class ServerNotConnected : P4APIExceptions
    {
        internal ServerNotConnected() { }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Attempting to run a command while the Perforce Server is not connected!\n";
            }
        }
    }

    /// <summary>
    /// Exception: Changing the port when a server is connected is not allowed!
    /// </summary>
    public class ServerAlreadyConnected : P4APIExceptions
    {
        internal ServerAlreadyConnected() { }

        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Changing the port when a server is connected is not allowed!\n";
            }
        }
    }

    /// <summary>
    /// Exception: Invalid login credentials.
    /// </summary>
    public class InvalidLogin : P4APIExceptions
    {
        private string _message;
        internal InvalidLogin(string Message) 
        {
            _message = Message;
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return String.Format("Invalid Login!\n{0}", _message) ;
            }
        }
    }

    /// <summary>
    /// Exception:  Attempting to set a property that can not be set after the server is connected!
    /// </summary>
    public class ServerNotConnected_SetVar_AfterInit : P4APIExceptions
    {
        internal ServerNotConnected_SetVar_AfterInit() { }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Attempting to set a property that can not be set after the server is connected!\n";
            }
        }
    }

    /// <summary>
    /// Exception: You can not use the '-o' and '-i' flags in Fetch_Form and Save_Form.
    /// </summary>
    public class InvalidFormArgument : P4APIExceptions
    {
        internal InvalidFormArgument() { }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "You can not use the '-o' and '-i' flags in Fetch_Form and Save_Form.\n";
            }
        }
    }

    /// <summary>
    /// Exception:  Unable to connect to the Perforce Server!
    /// </summary>
    public class PerforceInitializationError : P4APIExceptions
    {
        private string _P4Msg;
        internal PerforceInitializationError(string msg)
        {
            _P4Msg = msg;
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return String.Format("Unable to connect to the Perforce Server!\n{0}", _P4Msg);
            }
        }
    }

    /// <summary>
    /// Exception: Error attempting to fetch form.
    /// </summary>
    public class FormFetchException : P4APIExceptions
    {
        private string _P4Msg;
        private string _P4FormName;
        internal FormFetchException(string formName, string msg)
        {
            _P4Msg = msg;
            _P4FormName = formName;
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return String.Format("Error attempting to fetch form: {0}!\n{1}",_P4FormName, _P4Msg);
            }
        }
    }

    /// <summary>
    /// Exception: Interactive 'Form' commands are unsupported in P4API.
    /// Use the 'Fetch_Form' and 'Save_Form' methods of the P4Connection object.
    /// </summary>
    public class FormCommandException : P4APIExceptions
    {
        internal FormCommandException()
        {
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return "Interactive 'Form' commands are unsupported in P4API.\nUse the 'Fetch_Form' and 'Save_Form' methods of the P4Connection object.";
            }
        }
    }

    /// <summary>
    /// Exception: Error running Perforce command!
    /// </summary>
    public class RunUnParsedException : P4APIExceptions
    {
        private P4UnParsedRecordSet _rs;
        internal RunUnParsedException(P4UnParsedRecordSet rs)
        {
            _rs = rs;
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return String.Format("Error running Perforce command!\n{0}",_rs.ErrorMessage);
            }
        }

        /// <summary>
        /// Gets the P4UnParsedRecordSet that would have been returned if an exception was not thrown.
        /// </summary>
        public P4UnParsedRecordSet Result
        {
            get
            {
                return _rs;
            }
        }
    }

    /// <summary>
    /// Exception: Error running Perforce command!
    /// </summary>
    public class RunException : P4APIExceptions
    {
        private P4RecordSet _rs;
        internal RunException(P4RecordSet rs)
        {
            _rs = rs;
        }
        /// <summary>
        /// Gets the error message for the exception.
        /// </summary>
        public override string Message
        {
            get
            {
                return String.Format("Error running Perforce command!\n{0}", _rs.ErrorMessage);
            }
        }
    }
    
}
# Change User Description Committed
#1 7341 Erik Purins p4.net
---
pull p4.net#head
//guest/shawn_hladky/P4.Net/release/0.9/src/P4API/Exceptions/P4APIExceptions.cs
#1 5831 Shawn Hladky P4.Net: Branch release 0.9 and delete a few files missed last time
//guest/shawn_hladky/P4.Net/main/src/P4API/Exceptions/P4APIExceptions.cs
#1 5830 Shawn Hladky P4.Net: reorg to support release branches
//guest/shawn_hladky/P4.Net/src/P4API/Exceptions/P4APIExceptions.cs
#9 5798 Shawn Hladky P4.Net...  still not ready for beta
Added license to all files
Added several doc files
Misc bugs
#8 5774 Shawn Hladky P4.Net.
 A few bug fixes.  Addes first draft of MSBuild custom tasks.
#7 5636 Shawn Hladky 1.
 Added test harness framework, and some initial tests
2.  Fixed many bugs (oddly enough identified by the unit tests)
3.  Fixes so will build 1.1 Framework (and build batch files actually work)
4.  Pathetic attempt at documentation
#6 5433 Shawn Hladky P4.Net More refactoring
#5 5431 Shawn Hladky Refactoring...
step 1.
#4 5427 Shawn Hladky P4.Net -- several fixes and added sample application
#3 5373 Shawn Hladky P4.Net: Still WIP, but some things starting to work
#2 5362 Shawn Hladky Chipping away at the API changes
#1 5349 Shawn Hladky Initial check-in for the new API interface.
 Nothing works yet, but it should compile at least.