Class DomainException
- Namespace
- Excalibur.Domain.Exceptions
- Assembly
- Excalibur.Domain.dll
Represents a domain-level exception that occurs within the application's business logic.
public class DomainException : Exception, ISerializable
- Inheritance
-
DomainException
- Implements
- Derived
- Inherited Members
Remarks
Domain exceptions are pure business-logic errors that should not carry HTTP or API concerns. HTTP status code mapping belongs in the API/middleware layer, not in the domain.
Constructors
DomainException()
Initializes a new instance of the DomainException class with a default error message.
public DomainException()
DomainException(string)
Initializes a new instance of the DomainException class with a specified error message.
public DomainException(string message)
Parameters
messagestringA message describing the exception.
DomainException(string, Exception?)
Initializes a new instance of the DomainException class with a specified error message and an inner exception.
public DomainException(string message, Exception? innerException)
Parameters
messagestringA message describing the exception.
innerExceptionExceptionThe exception that caused the current exception.
Methods
ThrowIf(bool, string)
Throws a DomainException if the specified condition evaluates to true .
public static void ThrowIf(bool condition, string message)
Parameters
conditionboolThe condition that determines whether to throw the exception.
messagestringA message describing the exception.
Exceptions
- DomainException
Thrown if
conditionevaluates totrue.
ThrowIf(bool, string, Exception)
Throws a DomainException if the specified condition evaluates to true .
public static void ThrowIf(bool condition, string message, Exception innerException)
Parameters
conditionboolThe condition that determines whether to throw the exception.
messagestringA message describing the exception.
innerExceptionExceptionThe exception that caused the current exception.
Exceptions
- DomainException
Thrown if
conditionevaluates totrue.