summaryrefslogtreecommitdiffstats
path: root/src/Cepis/CepisException.cs
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-26 12:42:38 -0300
committerMurilo Ijanc <[email protected]>2026-07-26 13:10:34 -0300
commita2b10fd494fb389e556e40134031eb86e56e11e7 (patch)
tree08b6df8a06f2c7c15488b90d57a6d8286cd57a22 /src/Cepis/CepisException.cs
downloadcsharp-a2b10fd494fb389e556e40134031eb86e56e11e7.tar.gz
Initial importv0.1.0
Diffstat (limited to 'src/Cepis/CepisException.cs')
-rw-r--r--src/Cepis/CepisException.cs39
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)
+ {
+ }
+}