An error code is a numeric or alphamueric code that indicates the nature of an error and, when possible, why it occured.
Dapr error codes are standardized strings for over 80+ common errors across HTTP and gRPC requests when using the Dapr APIs. These codes are both:
Dapr error codes consist of a prefix, a category, and shorthand of the error itself. For example:
Prefix | Category | Error shorthand |
---|---|---|
ERR_ | PUBSUB_ | NOT_FOUND |
Some of the most common errors returned include:
An error returned for a state store not found might look like the following:
{
"error": "Bad Request",
"error_msg": "{\"errorCode\":\"ERR_STATE_STORE_NOT_FOUND\",\"message\":\"state store <name> is not found\",\"details\":[{\"@type\":\"type.googleapis.com/google.rpc.ErrorInfo\",\"domain\":\"dapr.io\",\"metadata\":{\"appID\":\"nodeapp\"},\"reason\":\"DAPR_STATE_NOT_FOUND\"}]}",
"status": 400
}
The returned error includes:
ERR_STATE_STORE_NOT_FOUND
state store <name> is not found
nodeapp
DAPR_STATE_NOT_FOUND
Metrics help you see when exactly errors are occuring from within the runtime. Error code metrics are collected using the error_code_total
endpoint. This endpoint is disabled by default. You can enable it using the recordErrorCodes
field in your configuration file.
Watch a demo presented during Diagrid’s Dapr v1.15 celebration to see how to enable error code metrics and handle error codes returned in the runtime.