using System; namespace PluginManager.Others.Exceptions { /// /// Custom Exception for PluginManager /// [Serializable] public class APIException : Exception { /// /// The function where the error occurred /// public string? Function { get; } = "not specified"; /// /// The error code /// public Error? ErrorCode { get; } = Error.UNKNOWN_ERROR; /// /// The possible cause that determined the error /// public string? PossibleCause { get; } = "not specified"; /// /// The APIException contructor /// /// The error message /// The function where the message was triggered /// The possible cause of the error /// The error code public APIException(string message, string? function, string possible_cause, Error error) : base(message) { ErrorCode = error; Function = function; PossibleCause = possible_cause; } /// /// The APIException contructor /// /// The error message /// The function where the message was triggered /// The error code public APIException(string message, string? function, Error? errorCode) : base(message) { ErrorCode = errorCode; Function = function; } /// /// The APIException contructor /// /// The error message /// The function where the message was triggered public APIException(string message, string? function) : base(message) { Function = function; } /// /// The APIException contructor /// /// The error message public APIException(string message) : base(message) { } /// /// Method to print the error to /// public void Print() { Console.WriteLine("Message Content: " + Message); Console.WriteLine("Function: " + Function); Console.WriteLine("Error Code: " + ErrorCode.ToString()); Console.WriteLine("Possible cause: " + PossibleCause); if (this.StackTrace != null) Functions.WriteErrFile(this.StackTrace); } } }