You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File and directory access, format, size, existence
EZXception.Network
Connections, DNS, SSL, proxy
EZXception.Serialization
Serialize/deserialize failures
EZXception.Concurrency
Deadlocks, resource locks, retry exhaustion
EZXception.Validation
usingEZXception.Validation;
ValidationException
Base exception. Supports collecting multiple errors in a single throw.
// Single messagethrownewValidationException("The request body is invalid.");// Multiple errors at oncevarerrors=new[]{"Email is required.","Username too short.","Date out of range."};thrownewValidationException("One or more validation errors occurred.",errors);// Wrapping an inner exceptionthrownewValidationException("Validation pipeline failed.",innerException);
// Auto message: "The field 'Email' is required and cannot be null or empty."thrownewRequiredFieldException("Email");// Custom messagethrownewRequiredFieldException("Email","An email address must be provided.");// With inner exceptionthrownewRequiredFieldException("Email","Email extraction failed.",innerException);
Property
Type
FieldName
string
InvalidFormatException
// Field name onlythrownewInvalidFormatException("PhoneNumber");// With expected formatthrownewInvalidFormatException("PhoneNumber","+1-555-000-0000");// With expected format and the bad value receivedthrownewInvalidFormatException("PhoneNumber","+1-555-000-0000",input);// Wrapping a parse exceptionthrownewInvalidFormatException("DateOfBirth","Failed to parse date.",innerException);
Property
Type
FieldName
string
ExpectedFormat
string?
ActualValue
object?
ValueOutOfRangeException
// Min and maxthrownewValueOutOfRangeException("Age",minValue:0,maxValue:120);// With the actual bad valuethrownewValueOutOfRangeException("Age",minValue:0,maxValue:120,actualValue:-5);// One-sided range — pass null for the unbounded sidethrownewValueOutOfRangeException("Price",minValue:0m,maxValue:null,actualValue:-9.99m);// Custom messagethrownewValueOutOfRangeException("StartDate","Start date must not be in the past.");// Custom message with inner exceptionthrownewValueOutOfRangeException("StartDate","Range check failed.",innerException);
Property
Type
FieldName
string
MinValue
object?
MaxValue
object?
ActualValue
object?
DuplicateValueException
// Field name onlythrownewDuplicateValueException("Username");// With the conflicting valuethrownewDuplicateValueException("Username","john_doe");// With inner exceptionthrownewDuplicateValueException("Username","Uniqueness check failed.",innerException);
Property
Type
FieldName
string
Value
object?
StringLengthException
// Max only — "Bio' must not exceed 500 characters. Actual length: 612."thrownewStringLengthException("Bio",actualLength:612,maxLength:500);// Min onlythrownewStringLengthException("Password",actualLength:4,minLength:8);// Both min and maxthrownewStringLengthException("Username",actualLength:1,minLength:3,maxLength:20);// With inner exceptionthrownewStringLengthException("Username","Length validation failed.",innerException);
Property
Type
FieldName
string
ActualLength
int
MinLength
int?
MaxLength
int?
EZXception.Authorization
usingEZXception.Authorization;
UnauthorizedException
Base exception for unauthenticated requests (HTTP 401). Use when the user has no valid session or token.
// Default: "Authentication is required to access this resource."thrownewUnauthorizedException();thrownewUnauthorizedException("Please log in to continue.");thrownewUnauthorizedException("Token validation failed.",innerException);
ForbiddenException
Authenticated but not permitted (HTTP 403).
// Default: "You do not have permission to perform this action."thrownewForbiddenException();thrownewForbiddenException("You cannot delete other users' posts.");// With the required permission namethrownewForbiddenException("Access denied.","posts:delete");thrownewForbiddenException("Permission check failed.",innerException);
Property
Type
RequiredPermission
string?
InvalidCredentialsException
// Default: "The provided credentials are invalid."thrownewInvalidCredentialsException();// Keep messages vague — don't reveal which field is wrongthrownewInvalidCredentialsException("Invalid email or password.");thrownewInvalidCredentialsException("Credential lookup failed.",innerException);
TokenExpiredException
// Default: "The authentication token has expired. Please re-authenticate."thrownewTokenExpiredException();// With expiry timestampthrownewTokenExpiredException(token.ExpiresAt);thrownewTokenExpiredException("Token decode failed.",innerException);
Property
Type
ExpiresAt
DateTimeOffset?
AccountLockedException
// "This account is locked. Please contact support."thrownewAccountLockedException();// With user IDthrownewAccountLockedException(userId:"user_42");// With user ID and unlock timethrownewAccountLockedException(userId:"user_42",lockedUntil:DateTimeOffset.UtcNow.AddMinutes(15));thrownewAccountLockedException("Lock check failed.",innerException);
Property
Type
UserId
string?
LockedUntil
DateTimeOffset?
InsufficientRoleException
// "Role 'Admin' is required to perform this action."thrownewInsufficientRoleException("Admin");// "Role 'Admin' is required, but user has role 'Viewer'."thrownewInsufficientRoleException("Admin",actualRole:user.Role);thrownewInsufficientRoleException("Role lookup failed.",innerException);
Property
Type
RequiredRole
string?
ActualRole
string?
EZXception.Data
usingEZXception.Data;
EntityNotFoundException
// "User was not found."thrownewEntityNotFoundException("User");// "User with id '42' was not found."thrownewEntityNotFoundException("User",id);thrownewEntityNotFoundException("DB read failed.",innerException);
Property
Type
EntityType
string?
EntityId
object?
DuplicateEntityException
// "A duplicate User already exists."thrownewDuplicateEntityException("User");// "A User with value 'john@example.com' already exists."thrownewDuplicateEntityException("User",conflictingValue:email);thrownewDuplicateEntityException("Duplicate check failed.",innerException);
Property
Type
EntityType
string?
ConflictingValue
object?
DataIntegrityException
Thrown on constraint violations (foreign key, unique index, check constraint).
thrownewDataIntegrityException("Cannot delete category — products are still assigned to it.");// With constraint name for loggingthrownewDataIntegrityException("FK constraint violated.",constraintName:"FK_Products_Category");thrownewDataIntegrityException("Constraint check failed.",innerException,"FK_Products_Category");
Property
Type
ConstraintName
string?
OptimisticConcurrencyException
Thrown when a record was modified by another process between your read and write.
// Generic messagethrownewOptimisticConcurrencyException();// With entity typethrownewOptimisticConcurrencyException(entityType:"Order");// With entity type and IDthrownewOptimisticConcurrencyException(entityType:"Order",entityId:orderId);thrownewOptimisticConcurrencyException("Concurrency check failed.",innerException);
Property
Type
EntityType
string?
EntityId
object?
DatabaseException
General DB failure — connection dropped, transaction failed, etc.
thrownewDatabaseException("Failed to connect to the database.");// With operation name for loggingthrownewDatabaseException("Transaction rollback failed.",operation:"CommitOrder");thrownewDatabaseException("DB operation failed.",innerException,operation:"BulkInsert");
Property
Type
Operation
string?
QueryException
Inherits DatabaseException. For invalid or failed queries.
thrownewQueryException("Invalid filter expression.");// With the query string for debuggingthrownewQueryException("Query execution failed.",query:"SELECT * FROM Orders WHERE ...");thrownewQueryException("Query failed.",innerException,query:rawQuery);
Property
Type
Query
string?
EZXception.Business
usingEZXception.Business;
BusinessRuleException
Base exception for domain/business rule violations.
thrownewBusinessRuleException("Orders cannot be placed outside of business hours.");// With rule name for structured loggingthrownewBusinessRuleException("Order placed outside business hours.",ruleName:"BusinessHoursOnly");thrownewBusinessRuleException("Rule evaluation failed.",innerException,ruleName:"BusinessHoursOnly");
Property
Type
RuleName
string?
InvalidStateTransitionException
// "Order cannot transition from 'Shipped' to 'Pending'."thrownewInvalidStateTransitionException("Order",fromState:"Shipped",toState:"Pending");// No entity typethrownewInvalidStateTransitionException(null,fromState:"Active",toState:"Draft");thrownewInvalidStateTransitionException("Transition check failed.",innerException);
Property
Type
EntityType
string?
FromState
string?
ToState
string?
WorkflowException
thrownewWorkflowException("Payment step failed: card declined.");// With workflow and step contextthrownewWorkflowException("Card declined.",workflowName:"Checkout",stepName:"Payment");thrownewWorkflowException("Step failed.",innerException,workflowName:"Checkout",stepName:"Payment");
Property
Type
WorkflowName
string?
StepName
string?
OperationNotAllowedException
// "Operation 'DeleteAccount' is not allowed: account has active subscriptions."thrownewOperationNotAllowedException("DeleteAccount",reason:"account has active subscriptions.");thrownewOperationNotAllowedException("Operation check failed.",innerException);
Property
Type
OperationName
string?
QuotaExceededException
// "Quota 'MonthlyAPIRequests' has been exceeded."thrownewQuotaExceededException("MonthlyAPIRequests");// With limitthrownewQuotaExceededException("MonthlyAPIRequests",limit:1000);// With limit and current usage — "Quota 'MonthlyAPIRequests' exceeded: 1001/1000."thrownewQuotaExceededException("MonthlyAPIRequests",limit:1000,current:1001);thrownewQuotaExceededException("Quota check failed.",innerException);
Thrown when an aggregate's always-true invariant is broken.
// "OrderTotal must always be >= 0" invariant violatedthrownewInvariantViolationException("OrderTotalNonNegative","Order total cannot be negative.");thrownewInvariantViolationException("OrderTotalNonNegative","Invariant check failed.",innerException);
Property
Type
InvariantName
string?
DomainName
string? (inherited)
AggregateRootException
Thrown when an operation crosses or violates an aggregate root boundary.
thrownewAggregateRootException("Order",aggregateId:orderId,"Cannot modify a completed order.");thrownewAggregateRootException("Order","Boundary check failed.",innerException);
Property
Type
AggregateType
string?
AggregateId
object?
EZXception.Configuration
usingEZXception.Configuration;
ConfigurationException
Base exception for all configuration errors.
thrownewConfigurationException("Configuration is in an invalid state.");thrownewConfigurationException("Config load failed.",configKey:"Smtp:Host");thrownewConfigurationException("Config load failed.",innerException,configKey:"Smtp:Host");
Property
Type
ConfigKey
string?
MissingConfigurationException
// "Required configuration key 'Smtp:Host' is missing."thrownewMissingConfigurationException("Smtp:Host");// Custom messagethrownewMissingConfigurationException("Smtp:Host","SMTP host must be configured before sending emails.");thrownewMissingConfigurationException("Smtp:Host","Config read failed.",innerException);
Property
Type
ConfigKey
string? (inherited)
InvalidConfigurationException
// "Configuration key 'Smtp:Port' has an invalid value."thrownewInvalidConfigurationException("Smtp:Port");// With the bad valuethrownewInvalidConfigurationException("Smtp:Port",actualValue:"abc");// With the bad value and what was expectedthrownewInvalidConfigurationException("Smtp:Port",actualValue:"abc",expectedDescription:"an integer between 1 and 65535");thrownewInvalidConfigurationException("Smtp:Port","Port parse failed.",innerException);
Thrown when an external HTTP API returns an error status code.
// "API call to 'Stripe' failed with status 400."thrownewApiException("Stripe",statusCode:400);// With response body for debuggingthrownewApiException("Stripe",statusCode:400,responseBody:responseContent);// With response body and the request URLthrownewApiException("Stripe",statusCode:400,responseBody:responseContent,requestUrl:requestUri);thrownewApiException("Stripe","Deserialization of error response failed.",innerException);
Property
Type
ServiceName
string? (inherited)
StatusCode
int?
ResponseBody
string?
RequestUrl
string?
ServiceUnavailableException
// "Service 'InventoryService' is currently unavailable. Please try again later."thrownewServiceUnavailableException("InventoryService");thrownewServiceUnavailableException("InventoryService","Service is under maintenance until 3 AM.");thrownewServiceUnavailableException("InventoryService","Health check failed.",innerException);
RateLimitException
// "Rate limit exceeded for service 'OpenAI'."thrownewRateLimitException("OpenAI");// With retry-after duration — "... Retry after 60 seconds."thrownewRateLimitException("OpenAI",retryAfter:TimeSpan.FromSeconds(60));thrownewRateLimitException("OpenAI","Rate limit parse failed.",innerException);
Property
Type
RetryAfter
TimeSpan?
OperationTimeoutException
// "Operation 'FetchUserProfile' on service 'UserService' timed out."thrownewOperationTimeoutException("UserService","FetchUserProfile");// With the actual timeout valuethrownewOperationTimeoutException("UserService","FetchUserProfile",timeout:TimeSpan.FromSeconds(30));thrownewOperationTimeoutException("UserService","Timeout handler threw.",innerException);
Property
Type
OperationName
string?
Timeout
TimeSpan?
EZXception.IO
usingEZXception.IO;
Note:EZFileNotFoundException, EZDirectoryNotFoundException, and EZSerializationException carry the EZ prefix to avoid compiler ambiguity with BCL types of the same name. See Naming Notes.
EZFileNotFoundException
// "File not found: '/uploads/avatar.png'."thrownewEZFileNotFoundException("/uploads/avatar.png");thrownewEZFileNotFoundException("/uploads/avatar.png","Profile picture is missing.");thrownewEZFileNotFoundException("/uploads/avatar.png","File read failed.",innerException);
Property
Type
FilePath
string?
FileAlreadyExistsException
// "File already exists: '/exports/report.csv'."thrownewFileAlreadyExistsException("/exports/report.csv");thrownewFileAlreadyExistsException("/exports/report.csv","A report for this period already exists.");thrownewFileAlreadyExistsException("/exports/report.csv","File creation failed.",innerException);
Property
Type
FilePath
string?
InvalidFileFormatException
// "File '/imports/data.csv' has an invalid or unrecognized format."thrownewInvalidFileFormatException("/imports/data.csv");// With expected formatthrownewInvalidFileFormatException("/imports/data.csv",expectedFormat:"CSV");thrownewInvalidFileFormatException("/imports/data.csv","Header row missing.",innerException);
Property
Type
FilePath
string?
ExpectedFormat
string?
FileSizeLimitException
// Auto-formats bytes — "File '/uploads/video.mp4' exceeds the maximum allowed size of 10.00 MB. Actual size: 54.20 MB."thrownewFileSizeLimitException("/uploads/video.mp4",maxSizeBytes:10_485_760,actualSizeBytes:56_817_254);thrownewFileSizeLimitException("/uploads/video.mp4","File too large.",innerException);
Property
Type
FilePath
string?
MaxSizeBytes
long?
ActualSizeBytes
long?
EZDirectoryNotFoundException
// "Directory not found: '/var/app/uploads'."thrownewEZDirectoryNotFoundException("/var/app/uploads");thrownewEZDirectoryNotFoundException("/var/app/uploads","Upload directory has not been provisioned.");thrownewEZDirectoryNotFoundException("/var/app/uploads","Directory check failed.",innerException);
Property
Type
DirectoryPath
string?
FileAccessException
// "Access to file '/data/config.json' was denied or the file is locked."thrownewFileAccessException("/data/config.json");// With access type — "Cannot write file '/data/config.json'. Access denied or file is locked."thrownewFileAccessException("/data/config.json",accessType:"write");thrownewFileAccessException("/data/config.json","Permission check failed.",innerException);
Property
Type
FilePath
string?
AccessType
string?
EZXception.Network
usingEZXception.Network;
NetworkException
Base exception for all network failures.
thrownewNetworkException("Network is unavailable.");thrownewNetworkException("Network call failed.",innerException);
ConnectionException
// Generic: "A network connection could not be established."thrownewConnectionException();// With hostthrownewConnectionException(host:"db.internal");// With host and port — "Could not connect to 'db.internal:5432'."thrownewConnectionException(host:"db.internal",port:5432);thrownewConnectionException("Socket error.",innerException);
Property
Type
Host
string?
Port
int?
DnsResolutionException
// "DNS resolution failed for host 'api.unknown-service.io'."thrownewDnsResolutionException("api.unknown-service.io");thrownewDnsResolutionException("api.unknown-service.io","DNS lookup timed out.",innerException);
Property
Type
Hostname
string?
SslCertificateException
// "SSL certificate error for 'api.example.com': certificate has expired."thrownewSslCertificateException("api.example.com",reason:"certificate has expired");thrownewSslCertificateException("SSL handshake failed.",innerException);
Property
Type
Host
string?
ProxyException
thrownewProxyException("Proxy returned 407 Proxy Authentication Required.");// With proxy address for loggingthrownewProxyException("Proxy auth failed.",proxyAddress:"http://proxy.corp:8080");thrownewProxyException("Proxy error.",innerException,proxyAddress:"http://proxy.corp:8080");
Property
Type
ProxyAddress
string?
EZXception.Serialization
usingEZXception.Serialization;
EZSerializationException
thrownewEZSerializationException("Failed to serialize order to JSON.");// With target formatthrownewEZSerializationException("Serialization failed.",targetFormat:"JSON");// With target format and the type being serializedthrownewEZSerializationException("Serialization failed.",targetFormat:"JSON",targetType:typeof(Order));thrownewEZSerializationException("Serializer threw.",innerException,targetFormat:"JSON",targetType:typeof(Order));
Property
Type
TargetFormat
string?
TargetType
Type?
DeserializationException
thrownewDeserializationException("Failed to deserialize webhook payload.");// With source formatthrownewDeserializationException("Deserialization failed.",sourceFormat:"JSON");// With source format and target typethrownewDeserializationException("Deserialization failed.",sourceFormat:"JSON",targetType:typeof(WebhookEvent));// With raw input captured for debuggingthrownewDeserializationException("Deserialization failed.",sourceFormat:"JSON",targetType:typeof(WebhookEvent),rawInput:body);thrownewDeserializationException("Parser threw.",innerException,sourceFormat:"JSON",targetType:typeof(WebhookEvent));
Property
Type
SourceFormat
string?
TargetType
Type?
RawInput
string?
EZXception.Concurrency
usingEZXception.Concurrency;
DeadlockException
// Default: "A deadlock was detected. The operation cannot proceed."thrownewDeadlockException();thrownewDeadlockException("Deadlock detected between Order and Inventory locks.");thrownewDeadlockException("Lock acquisition threw.",innerException);
ResourceLockException
// Generic: "A required resource is currently locked and cannot be acquired."thrownewResourceLockException();// "Resource 'ReportGenerator' is currently locked and cannot be acquired."thrownewResourceLockException(resourceName:"ReportGenerator");thrownewResourceLockException("ReportGenerator","Lock acquisition failed.",innerException);
Property
Type
ResourceName
string?
MaxRetryExceededException
// "Operation failed after 5 retry attempts."thrownewMaxRetryExceededException(attempts:5);// "Operation 'SendEmail' failed after 3 attempts."thrownewMaxRetryExceededException(attempts:3,operationName:"SendEmail");// With the last inner exceptionthrownewMaxRetryExceededException(attempts:3,operationName:"SendEmail",innerException:lastException);