Class OperationFailedException
Represents an exception that is thrown when an operation fails to execute successfully on a specific resource.
public sealed class OperationFailedException : ResourceException, ISerializable
- Inheritance
-
OperationFailedException
- Implements
- Inherited Members
Remarks
This exception can be used to encapsulate information about failed operations, including the name of the operation and the resource involved.
Constructors
OperationFailedException(string, int?, string?, Exception?)
Initializes a new instance of the ResourceException class with resource information.
public OperationFailedException(string resource, int? statusCode, string? message = null, Exception? innerException = null)
Parameters
resourcestringThe type or name of the resource associated with the error.
statusCodeint?The HTTP status code representing the error. Defaults to 404.
messagestringA custom error message. Defaults to a generic message using the resource name.
innerExceptionExceptionThe inner exception that caused this exception, if applicable.
OperationFailedException(string, string, int?, string?, Exception?)
Initializes a new instance of the OperationFailedException class.
public OperationFailedException(string operation, string resource, int? statusCode = null, string? message = null, Exception? innerException = null)
Parameters
operationstringThe name of the operation that failed.
resourcestringThe name or type of the resource associated with the operation.
statusCodeint?The HTTP status code associated with the failure. Defaults to DefaultStatusCode.
messagestringA custom error message describing the failure. Defaults to DefaultMessage.
innerExceptionExceptionThe inner exception that caused this exception, if applicable.
Fields
DefaultMessage
The default error message for operation failures.
public const string DefaultMessage = "The operation failed."
Field Value
DefaultStatusCode
The default HTTP status code for operation failures.
public const int DefaultStatusCode = 500
Field Value
Properties
Operation
Gets or sets the name of the operation that failed.
public string Operation { get; set; }
Property Value
- string
A string representing the operation name.