Table of Contents

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

message string

A 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

message string

A message describing the exception.

innerException Exception

The 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

condition bool

The condition that determines whether to throw the exception.

message string

A message describing the exception.

Exceptions

DomainException

Thrown if condition evaluates to true .

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

condition bool

The condition that determines whether to throw the exception.

message string

A message describing the exception.

innerException Exception

The exception that caused the current exception.

Exceptions

DomainException

Thrown if condition evaluates to true .