using System; namespace PluginManager.Others.Exceptions; /// /// Custom Exception for PluginManager /// [Serializable] public class APIException : Exception { /// /// 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) { } /// /// The APIException constructor /// /// The error message /// The class where the error was thrown public APIException(string message, Type errorLocation) : base(message) { Function = errorLocation.FullName; } /// /// 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"; /// /// Method to print the error to /// public void Print() { Console.WriteLine("Message Content: " + Message); Console.WriteLine("Function: " + Function); Console.WriteLine("Error Code: " + ErrorCode); Console.WriteLine("Possible cause: " + PossibleCause); if (StackTrace != null) Functions.WriteErrFile(StackTrace); } }