package
0.13.2
Repository: https://github.com/dapr/kit.git
Documentation: pkg.go.dev

# README

Errors

The standardizing of errors to be used in Dapr based on the gRPC Richer Error Model and accepted dapr/proposal.

Usage

Define the error

import kitErrors "github.com/dapr/kit/errors"

// Define error in dapr pkg/api/errors/<building_block>.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

import apiErrors "github.com/dapr/dapr/pkg/api/errors"

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

# Functions

FromError takes in an error and returns back the kitError if it's that type under the hood.
NewBuilder create a new ErrorBuilder using the supplied required error fields.

# Constants

No description provided by the author
No description provided by the author
Generic.
No description provided by the author
State.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Components.
No description provided by the author

# Structs

Error implements the Error interface and the interface that complies with "google.golang.org/grpc/status".FromError().
ErrorBuilder is used to build the error.