galaeth-draft/Galaeth.Core/Exceptions/ServiceException.cs
2024-11-17 09:31:01 +00:00

51 lines
1.5 KiB
C#

using System.Net;
namespace Galaeth.Core.Exceptions;
/// <summary>
/// Service exception to be fed back into the response.
/// </summary>
public class ServiceException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="ServiceException"/> class.
/// </summary>
/// <param name="errorCode">Error code to provide.</param>
/// <param name="errorMessage">Error message to provide.</param>
public ServiceException(string errorCode, string errorMessage)
: base(errorMessage)
{
ErrorCode = errorCode;
ErrorMessage = errorMessage;
}
/// <summary>
/// Initializes a new instance of the <see cref="ServiceException"/> class.
/// </summary>
/// <param name="errorCode">Error code to provide.</param>
/// <param name="errorMessage">Error message to provide.</param>
/// <param name="httpStatusCode">The http status code to provide.</param>
public ServiceException(string errorCode, string errorMessage, HttpStatusCode httpStatusCode)
: base(errorMessage)
{
ErrorCode = errorCode;
ErrorMessage = errorMessage;
HttpStatusCode = httpStatusCode;
}
/// <summary>
/// Standard error code.
/// </summary>
public string ErrorCode { get; }
/// <summary>
/// Error message.
/// </summary>
public string ErrorMessage { get; }
/// <summary>
/// Http Status Code.
/// </summary>
public HttpStatusCode HttpStatusCode { get; } = HttpStatusCode.BadRequest;
}