Skip to content

CommerceExceptions

// RB2 Core Connect
namespace CoreConnect.Commerce.Exceptions;
public class CommerceException : Exception
{
public int StatusCode { get; set; }
public CommerceErrorModel CommerceError { get; set; }
public CommerceException(int statusCode, string code, string message, string referenceCode = "") : base($"{code} : {message}")
{
StatusCode = statusCode;
CommerceError = new CommerceErrorModel(code, message, referenceCode, null, statusCode);
}
public CommerceException(CommerceErrorModel commerceError, Exception? innerException = null) : base($"{commerceError.Code} : {commerceError.Message}", innerException)
{
CommerceError = commerceError;
}
}
public class RequiredCommerceException : CommerceException
{
public RequiredCommerceException(int statusCode, string message, string referenceCode = "")
: base(statusCode, ErrorCodes.BAD_USER_INPUT, message, referenceCode) { }
}
public class ForbiddenCommerceException : CommerceException
{
public ForbiddenCommerceException(int statusCode, string message = "Access to resource is forbidden", string referenceCode = "")
: base(statusCode, ErrorCodes.FORBIDDEN, message, referenceCode) { }
}