using System;
using System.Text;
namespace P4API.Exceptions
{
///
/// Base exception for P4API.
///
public class P4APIExceptions : System.Exception
{
internal P4APIExceptions(){}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Generic P4API exception!";
}
}
}
///
/// Exception: Attempting to run a command while the Perforce Server is not connected!
///
public class ServerNotConnected : P4APIExceptions
{
internal ServerNotConnected() { }
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Attempting to run a command while the Perforce Server is not connected!\n";
}
}
}
///
/// Exception: Changing the port when a server is connected is not allowed!
///
public class ServerAlreadyConnected : P4APIExceptions
{
internal ServerAlreadyConnected() { }
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Changing the port when a server is connected is not allowed!\n";
}
}
}
///
/// Exception: Invalid login credentials.
///
public class InvalidLogin : P4APIExceptions
{
private string _message;
internal InvalidLogin(string Message)
{
_message = Message;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Invalid Login!\n{0}", _message) ;
}
}
}
///
/// Exception: Attempting to set a property that can not be set after the server is connected!
///
public class ServerNotConnected_SetVar_AfterInit : P4APIExceptions
{
internal ServerNotConnected_SetVar_AfterInit() { }
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Attempting to set a property that can not be set after the server is connected!\n";
}
}
}
///
/// Exception: You can not use the '-o' and '-i' flags in Fetch_Form and Save_Form.
///
public class InvalidFormArgument : P4APIExceptions
{
internal InvalidFormArgument() { }
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "You can not use the '-o' and '-i' flags in Fetch_Form and Save_Form.\n";
}
}
}
///
/// Exception: Unable to connect to the Perforce Server!
///
public class PerforceInitializationError : P4APIExceptions
{
private string _P4Msg;
internal PerforceInitializationError(string msg)
{
_P4Msg = msg;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Unable to connect to the Perforce Server!\n{0}", _P4Msg);
}
}
}
///
/// Exception: Error attempting to fetch form.
///
public class FormFetchException : P4APIExceptions
{
private string _P4Msg;
private string _P4FormName;
internal FormFetchException(string formName, string msg)
{
_P4Msg = msg;
_P4FormName = formName;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Error attempting to fetch form: {0}!\n{1}",_P4FormName, _P4Msg);
}
}
}
///
/// Exception: Interactive 'Form' commands are unsupported in P4API.
/// Use the 'Fetch_Form' and 'Save_Form' methods of the P4Connection object.
///
public class FormCommandException : P4APIExceptions
{
internal FormCommandException()
{
}
///
/// Gets the error message for the exception.
///
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.";
}
}
}
///
/// Exception: Error running Perforce command!
///
public class RunUnParsedException : P4APIExceptions
{
private P4UnParsedRecordSet _rs;
internal RunUnParsedException(P4UnParsedRecordSet rs)
{
_rs = rs;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Error running Perforce command!\n{0}",_rs.ErrorMessage);
}
}
///
/// Gets the P4UnParsedRecordSet that would have been returned if an exception was not thrown.
///
public P4UnParsedRecordSet Result
{
get
{
return _rs;
}
}
}
///
/// Exception: Error running Perforce command!
///
public class RunException : P4APIExceptions
{
private P4RecordSet _rs;
internal RunException(P4RecordSet rs)
{
_rs = rs;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Error running Perforce command!\n{0}", _rs.ErrorMessage);
}
}
}
}