diff options
Diffstat (limited to 'src/Cepis/CepisException.cs')
| -rw-r--r-- | src/Cepis/CepisException.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Cepis/CepisException.cs b/src/Cepis/CepisException.cs new file mode 100644 index 0000000..50af442 --- /dev/null +++ b/src/Cepis/CepisException.cs @@ -0,0 +1,39 @@ +namespace Cepis; + +/// <summary> +/// The base of every error this library raises. Catch it to handle any failure. +/// </summary> +/// <remarks> +/// <para> +/// Below this type the split is by <b>the decision the caller has to make</b>, +/// not by the HTTP status that caused it. +/// <see cref="InvalidCepException"/> and <see cref="CepNotFoundException"/> are +/// problems with the <i>request</i>: retrying is pointless, the same CEP will +/// fail again. <see cref="NetworkException"/>, <see cref="ServerErrorException"/> +/// and <see cref="RateLimitedException"/> are problems with <i>transport</i>: +/// retrying may help, and the client already retried on its own before throwing +/// any of them. +/// </para> +/// <para> +/// C# allows one base class, so these are not also <see cref="ArgumentException"/> +/// or <see cref="KeyNotFoundException"/>: one base type that catches every +/// failure is worth more. +/// </para> +/// </remarks> +public abstract class CepisException : Exception +{ + /// <summary>Create the exception with a message.</summary> + /// <param name="message">what went wrong</param> + protected CepisException(string message) + : base(message) + { + } + + /// <summary>Create the exception with a message and an underlying cause.</summary> + /// <param name="message">what went wrong</param> + /// <param name="innerException">the failure underneath, if any</param> + protected CepisException(string message, Exception? innerException) + : base(message, innerException) + { + } +} |