-
Notifications
You must be signed in to change notification settings - Fork 756
Error codes #3908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Error codes #3908
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6998990
Adds a general docs/reference page for the richer error model
elena-kolevska 992cd5b
Adds a note about not all errors being enriched
elena-kolevska accbf7b
Apply suggestions from code review
elena-kolevska 3577571
Merge branch 'v1.13' into error-codes
msfussell 3a676db
Apply suggestions from code review
elena-kolevska de0f222
Merge branch 'v1.13' into error-codes
msfussell d71bd4b
Apply suggestions from code review
elena-kolevska e16d22f
Small fixes after review
elena-kolevska 63858ae
Small update
elena-kolevska 29fc98b
Add related links
elena-kolevska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
type: docs | ||
title: Dapr errors | ||
linkTitle: "Dapr errors" | ||
weight: 700 | ||
description: "Information on Dapr errors and how to handle them" | ||
--- | ||
|
||
## Error handling: Understanding errors model and reporting | ||
|
||
Initially, errors followed the [Standard gRPC error model](https://grpc.io/docs/guides/error/#standard-error-model). However, to provide more detailed and informative error messages, an enhanced error model has been defined which aligns with the gRPC [Richer error model](https://grpc.io/docs/guides/error/#richer-error-model). | ||
|
||
{{% alert title="Note" color="primary" %}} | ||
Not all Dapr errors have been converted to the richer gRPC error model. | ||
{{% /alert %}} | ||
|
||
### Standard gRPC Error Model | ||
|
||
The [Standard gRPC error model](https://grpc.io/docs/guides/error/#standard-error-model) is an approach to error reporting in gRPC. Each error response includes an error code and an error message. The error codes are standardized and reflect common error conditions. | ||
|
||
**Example of a Standard gRPC Error Response:** | ||
``` | ||
ERROR: | ||
Code: InvalidArgument | ||
Message: input key/keyPrefix 'bad||keyname' can't contain '||' | ||
``` | ||
|
||
### Richer gRPC Error Model | ||
elena-kolevska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The [Richer gRPC error model](https://grpc.io/docs/guides/error/#richer-error-model) extends the standard error model by providing additional context and details about the error. This model includes the standard error `code` and `message`, along with a `details` section that can contain various types of information, such as `ErrorInfo`, `ResourceInfo`, and `BadRequest` details. | ||
|
||
|
||
**Example of a Richer gRPC Error Response:** | ||
elena-kolevska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
ERROR: | ||
Code: InvalidArgument | ||
Message: input key/keyPrefix 'bad||keyname' can't contain '||' | ||
Details: | ||
1) { | ||
"@type": "type.googleapis.com/google.rpc.ErrorInfo", | ||
"domain": "dapr.io", | ||
"reason": "DAPR_STATE_ILLEGAL_KEY" | ||
} | ||
2) { | ||
"@type": "type.googleapis.com/google.rpc.ResourceInfo", | ||
"resourceName": "statestore", | ||
"resourceType": "state" | ||
} | ||
3) { | ||
"@type": "type.googleapis.com/google.rpc.BadRequest", | ||
"fieldViolations": [ | ||
{ | ||
"field": "bad||keyname", | ||
"description": "input key/keyPrefix 'bad||keyname' can't contain '||'" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
For HTTP clients, Dapr translates the gRPC error model to a similar structure in JSON format. The response includes an `errorCode`, a `message`, and a `details` array that mirrors the structure found in the richer gRPC model. | ||
elena-kolevska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
**Example of an HTTP error response:** | ||
```json | ||
{ | ||
"errorCode": "ERR_MALFORMED_REQUEST", | ||
"message": "api error: code = InvalidArgument desc = input key/keyPrefix 'bad||keyname' can't contain '||'", | ||
"details": [ | ||
{ | ||
"@type": "type.googleapis.com/google.rpc.ErrorInfo", | ||
"domain": "dapr.io", | ||
"metadata": null, | ||
"reason": "DAPR_STATE_ILLEGAL_KEY" | ||
}, | ||
{ | ||
"@type": "type.googleapis.com/google.rpc.ResourceInfo", | ||
"description": "", | ||
"owner": "", | ||
"resource_name": "statestore", | ||
"resource_type": "state" | ||
}, | ||
{ | ||
"@type": "type.googleapis.com/google.rpc.BadRequest", | ||
"field_violations": [ | ||
{ | ||
"field": "bad||keyname", | ||
"description": "api error: code = InvalidArgument desc = input key/keyPrefix 'bad||keyname' can't contain '||'" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
You can find the specification of all the possible status details [here](https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto). | ||
|
||
## Related Links | ||
|
||
- [Authoring error codes](https://github.com/dapr/dapr/tree/master/pkg/api/errors) | ||
- [Using error codes in the Go SDK](https://docs.dapr.io/developing-applications/sdks/go/go-client/#error-handling) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.