/*
* P4.Net *
Copyright (c) 2007-2010 Shawn Hladky
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
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);
}
}
}
///
/// Error parsing the form spec.
///
public class FormParseException : P4APIExceptions
{
private string _P4Msg;
private string _P4FormName;
internal FormParseException(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 parse form: {0}!\n{1}", _P4FormName, _P4Msg);
}
}
}
///
/// Support for diff (without -s* flag) not yet implemented
///
public class DiffNotImplemented : P4APIExceptions
{
internal DiffNotImplemented()
{
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Support for diff (without -s* flag) not yet implemented";
}
}
}
///
/// Support for merging not yet implemented
///
public class MergeNotImplemented : P4APIExceptions
{
internal MergeNotImplemented()
{
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return "Support for merging not yet implemented";
}
}
}
///
/// 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);
}
}
}
///
/// ClientUser ErrorPause method was called. This in unsupported in P4.Net.
///
/// If you see this, please let the curator know the steps to reproduce. This should not be reachable code.
public class ErrorPauseCalled : P4APIExceptions
{
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("If you see this, please let the curator know the steps to reproduce. This should not be reachable code.");
}
}
}
///
/// Exception: File not found!
///
public class FileNotFound : P4APIExceptions
{
private string _depotPath;
internal FileNotFound(string depotPath)
{
_depotPath = depotPath;
}
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Perforce file not found: {0}!\n", _depotPath);
}
}
}
///
/// Exception: Can not write to stream.
///
public class StreamNotWriteable : P4APIExceptions
{
///
/// Gets the error message for the exception.
///
public override string Message
{
get
{
return String.Format("Unable to write to stream!\n");
}
}
}
}