Skip to main content
More

Errors

Rivet provides robust error handling with security built in by default. Errors are handled differently based on whether they should be exposed to clients or kept private.

There are two types of errors:

  • UserError: Thrown from actors and safely returned to clients with full details
  • Internal errors: All other errors that are converted to a generic error message for security

Throwing and Catching Errors

UserError lets you throw custom errors that will be safely returned to the client.

Throw a UserError with just a message:

Error Codes

Use error codes for explicit error matching in try-catch blocks: