Skip to content
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

Feat standardize err msgs #77

Merged
merged 39 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6826d9d
Move dapr/concurrency to kit (#72)
ItalyPaleAle Oct 30, 2023
48b95e2
Move `pkg/signals` from dapr/dapr to kit (#70)
ItalyPaleAle Oct 30, 2023
9162d54
Move dapr/utils/streams to kit (#68)
ItalyPaleAle Oct 31, 2023
2ab22e2
Migrate metadata decoder from components-contrib to kit (#74)
ItalyPaleAle Oct 31, 2023
8ca4cab
initial standardized err pkg: errfmt
cicoyle Nov 9, 2023
4810970
tweaks to error pkg and update tests. need to confirm reason
cicoyle Nov 13, 2023
807d965
cleanup test
cicoyle Nov 15, 2023
b538e17
add new func for err. change to protojson for http. need to figure ou…
cicoyle Nov 18, 2023
28af426
update status name
cicoyle Nov 20, 2023
8e881f1
wip: update JSONErrorValue
cicoyle Nov 21, 2023
19b51bc
Updates err to json conversion. Organises error messages and codes
elena-kolevska Nov 27, 2023
8c763b8
add type to http json output. tests are a WIP
cicoyle Nov 28, 2023
11b364b
add all details, update tests, prefixes/postfixes
cicoyle Nov 30, 2023
c160e1f
add README
cicoyle Nov 30, 2023
5d25c9e
use strongly-typed struct for errJSON
cicoyle Dec 1, 2023
5d1d96e
update README
cicoyle Dec 1, 2023
a10f23c
Adds the option to add a help link detail and a field violation detail
elena-kolevska Dec 5, 2023
55b7257
Update fswatcher to use /events/batcher (#75)
JoshVanL Nov 16, 2023
063c75a
Adds tests for WithHelp and err.WithFieldViolation
elena-kolevska Dec 5, 2023
97cae3e
rebase and update proto field access to rebased code
cicoyle Dec 11, 2023
e42cbfb
gofumpt
cicoyle Dec 11, 2023
8ec73ae
errJson -> errJSON and update proto field access
cicoyle Dec 11, 2023
f4e3543
HttpCode -> HTTPCode per CI warnings
cicoyle Dec 11, 2023
a991b12
Merge branch 'dapr:main' into feat-standardize-err-msgs
cicoyle Dec 11, 2023
44a14d5
rm reason since its not used
cicoyle Dec 11, 2023
1a55af0
update return type in README example
cicoyle Dec 11, 2023
d50e447
use builder, add errorInfo check to Build(), update and add tests for…
cicoyle Dec 12, 2023
993b20f
appease CI
cicoyle Dec 12, 2023
7c071cc
update README
cicoyle Dec 12, 2023
976c0ec
make GRPCStatus val receiver
cicoyle Dec 13, 2023
918ce8f
Update messages.go
artursouza Dec 14, 2023
1be4de2
add test to ensure we have a switch for all google err_detail types
cicoyle Dec 15, 2023
656df7f
rebase and update log
cicoyle Dec 15, 2023
0901f75
re-export ErrorBuilder
cicoyle Dec 15, 2023
8e597f8
Update errors/errors.go
cicoyle Dec 15, 2023
5c6dcf3
use ast pkg to dynamically grab our errTypes in the switch case inste…
cicoyle Dec 15, 2023
cbfa8a5
appease CI
cicoyle Dec 15, 2023
31585da
add FromError func
cicoyle Dec 18, 2023
b4bce9b
account for error wrapping
cicoyle Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions errors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Errors

The standardizing of errors to be used in Dapr based on the gRPC Richer Error Model and [accepted dapr/proposal](https://github.com/dapr/proposals/blob/main/0009-BCIRS-error-handling-codes.md).

## Usage

Define the error
```go
import kitErrors "github.com/dapr/kit/errors"

// Define error in dapr pkg/api/<building_block>_errors.go
func PubSubNotFound(name string, pubsubType string, metadata map[string]string) error {
message := fmt.Sprintf("pubsub %s is not found", name)

return kitErrors.NewBuilder(
grpcCodes.NotFound,
http.StatusBadRequest,
message,
kitErrors.CodePrefixPubSub+kitErrors.CodeNotFound,
).
WithErrorInfo(kitErrors.CodePrefixPubSub+kitErrors.CodeNotFound, metadata).
WithResourceInfo(pubsubType, name, "", message).
Build()
}
```

Use the error
```go
import apiErrors "github.com/dapr/dapr/pkg/api/errors"

// Use error in dapr and pass in relevant information
err = apiErrors.PubSubNotFound(pubsubName, pubsubType, metadata)

```
37 changes: 37 additions & 0 deletions errors/codes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package errors

const (
// Generic
CodeNotFound = "NOT_FOUND"
CodeNotConfigured = "NOT_CONFIGURED"
CodeNotSupported = "NOT_SUPPORTED"
CodeIllegalKey = "ILLEGAL_KEY"

// Components
CodePrefixStateStore = "DAPR_STATE_"
CodePrefixPubSub = "DAPR_PUBSUB_"
CodePrefixBindings = "DAPR_BINDING_"
CodePrefixSecretStore = "DAPR_SECRET_"
CodePrefixConfigurationStore = "DAPR_CONFIGURATION_"
CodePrefixLock = "DAPR_LOCK_"
CodePrefixNameResolution = "DAPR_NAME_RESOLUTION_"
CodePrefixMiddleware = "DAPR_MIDDLEWARE_"

// State
CodePostfixGetStateFailed = "GET_STATE_FAILED"
CodePostfixTooManyTransactions = "TOO_MANY_TRANSACTIONS"
CodePostfixQueryFailed = "QUERY_FAILED"
)
Loading
Loading