Skip to content

Exception handling

CommerceException Class

The CommerceException class is a custom exception derived from the standard Exception class. It is used to encapsulate and convey information about exceptions that occur during commerce-related operations.

Properties

StatusCode: An integer property that represents the HTTP status code associated with the exception.

CommerceError: An instance of the CommerceErrorModel class containing information about the error, such as error code, message, and reference code.

RequiredCommerceException Class

The RequiredCommerceException class is a specific subclass of CommerceException. It is designed to handle cases where input validation fails or required data is missing, leading to a “Bad User Input” scenario.

ForbiddenCommerceException Class

The ForbiddenCommerceException class is another specific subclass of CommerceException. It is intended to handle situations where access to a resource is denied or forbidden.

Error Messages

An overview of custom error messages used in Core Connect. These custom error messages are integral to specific issues and provides a meaningful feedback to users and developers when handling various scenarios.

CredentialsValidationError

  • Error Code: BAD_USER_INPUT
  • Message: “Invalid credentials”
  • Reference Code: InvalidCredentials

This error is raised when the provided credentials, such as username and password, are invalid or incorrect. It indicates that the authentication or authorization process failed due to credentials validation issues.

SignInProfileError

  • Error Code: BAD_REQUEST
  • Message: “Unable to fetch customer profile.”
  • Reference Code: ProfileError

This error occurs when the application is unable to retrieve the customer’s profile information during the sign-in process. It indicates a failure to fetch the customer’s details.

CustomerNotFound

  • Error Code: BAD_REQUEST
  • Message: “Unable to find a customer with the provided email.”
  • Reference Code: CustomerNotFound

This error is raised when the application is unable to locate a customer with the provided email address. It signifies that the requested customer does not exist in the system’s database.

AttributeNotFound

  • Error Code: BAD_REQUEST
  • Message: “Unable to get the provided attribute.”
  • Reference Code: InvalidAttribute

This error occurs when the application is unable to retrieve a specified attribute or data field. It indicates a failure to access the requested attribute.

TokenMismatch

  • Error Code: BAD_REQUEST
  • Message: “Unable to reset password. Reset token is invalid.”
  • Reference Code: InvalidToken

This error is raised when an attempt to reset a password fails due to an invalid or expired reset token. It indicates that the provided token is no longer valid for the requested action.

Possible Causes:
  • Expired or non-existent reset token.
  • Attempting to use a token multiple times.

TokenAlreadyUsedError

  • Error Code: BAD_REQUEST
  • Message: “Token is now outdated.”
  • Reference Code: TokenOutdated

This error occurs when a token, typically related to a specific operation has already been used and is no longer valid. It signifies that the token has served its purpose.

PasswordUnchangedError

  • Error Code: BAD_REQUEST
  • Message: “The new password needs to be different from the old one.”
  • Reference Code: PasswordUnchanged

This error is raised when an attempt to change a password results in the new password being identical to the old one. It indicates that the new password does not meet the required change criteria.

AddressNotFound

  • Error Code: NOT_FOUND
  • Message: “Invalid address ID.”
  • Reference Code: AddressNotFound

This error occurs when an attempt to access an address with an invalid or non-existent address ID is made. It signifies that the requested address cannot be found.

CartUpdateError

  • Error Code: BAD_REQUEST
  • Message: “Unable to update cart.”
  • Reference Code: CartUpdateFailed

This error is raised when an attempt to update a shopping cart fails, typically due to issues such as data inconsistency or an incorrect update process.