Skip to content

Commit 341b531

Browse files
committed
Simplify ApiException
1 parent 74f13ea commit 341b531

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

src/Initium/Exceptions/ApiException.cs

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,16 @@ namespace Initium.Exceptions;
99
[SuppressMessage("ReSharper", "UnusedMember.Global")]
1010
public class ApiException : Exception
1111
{
12-
/// <summary>
13-
/// Gets the HTTP status code associated with this exception.
14-
/// </summary>
1512
public HttpStatusCode StatusCode { get; }
16-
17-
/// <summary>
18-
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified HTTP status code.
19-
/// </summary>
20-
/// <param name="statusCode">The HTTP status code associated with this exception.</param>
21-
public ApiException(HttpStatusCode statusCode = HttpStatusCode.InternalServerError)
22-
{
23-
StatusCode = statusCode;
24-
}
2513

2614
/// <summary>
27-
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified HTTP status code and message.
28-
/// </summary>
29-
/// <param name="statusCode">The HTTP status code associated with this exception.</param>
30-
/// <param name="message">The message describing the error.</param>
31-
public ApiException(HttpStatusCode statusCode, string message) : base(message)
32-
{
33-
StatusCode = statusCode;
34-
}
35-
36-
/// <summary>
37-
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified message.
38-
/// </summary>
39-
/// <param name="message">The message describing the error.</param>
40-
public ApiException(string message) : base(message)
41-
{
42-
// TODO: Define proper error code.
43-
// StatusCode = statusCode;
44-
}
45-
46-
/// <summary>
47-
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified HTTP status code, message, and inner exception.
15+
/// Initializes a new instance of the <see cref="ApiException"/> class with a specified HTTP status code, message, and optional inner exception.
4816
/// </summary>
49-
/// <param name="statusCode">The HTTP status code associated with this exception.</param>
50-
/// <param name="message">The message describing the error.</param>
51-
/// <param name="innerException">The inner exception that caused the current exception.</param>
52-
public ApiException(HttpStatusCode statusCode, string message, Exception? innerException) : base(message, innerException)
17+
/// <param name="statusCode">The HTTP status code associated with this exception. Defaults to <see cref="HttpStatusCode.InternalServerError"/>.</param>
18+
/// <param name="message">The message describing the error. Defaults to a generic error message.</param>
19+
/// <param name="innerException">The inner exception that caused the current exception. Optional.</param>
20+
public ApiException(HttpStatusCode statusCode = HttpStatusCode.InternalServerError, string? message = null, Exception? innerException = null)
21+
: base(message ?? "An error occurred during API processing.", innerException)
5322
{
5423
StatusCode = statusCode;
5524
}

0 commit comments

Comments
 (0)