errors

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package errors contains custom error codes that are sent to clients.

Index

Constants

View Source
const InternalServerErrorMsg = "Internal Server Error"

Variables

View Source
var (
	// AuthorizationModelResolutionTooComplex is used to avoid stack overflows
	AuthorizationModelResolutionTooComplex = status.Error(codes.Code(openfgav1.ErrorCode_authorization_model_resolution_too_complex), "Authorization Model resolution required too many rewrite rules to be resolved. Check your authorization model for infinite recursion or too much nesting")
	InvalidWriteInput                      = status.Error(codes.Code(openfgav1.ErrorCode_invalid_write_input), "Invalid input. Make sure you provide at least one write, or at least one delete")
	InvalidContinuationToken               = status.Error(codes.Code(openfgav1.ErrorCode_invalid_continuation_token), "Invalid continuation token")
	InvalidExpandInput                     = status.Error(codes.Code(openfgav1.ErrorCode_invalid_expand_input), "Invalid input. Make sure you provide an object and a relation")
	UnsupportedUserSet                     = status.Error(codes.Code(openfgav1.ErrorCode_unsupported_user_set), "Userset is not supported (right now)")
	StoreIDNotFound                        = status.Error(codes.Code(openfgav1.NotFoundErrorCode_store_id_not_found), "Store ID not found")
	MismatchObjectType                     = status.Error(codes.Code(openfgav1.ErrorCode_query_string_type_continuation_token_mismatch), "The type in the querystring and the continuation token don't match")
	RequestCancelled                       = status.Error(codes.Code(openfgav1.InternalErrorCode_cancelled), "Request Cancelled")
	RequestDeadlineExceeded                = status.Error(codes.Code(openfgav1.InternalErrorCode_deadline_exceeded), "Request Deadline Exceeded")
)

Functions

func AssertionsNotForAuthorizationModelFound

func AssertionsNotForAuthorizationModelFound(modelID string) error

func AuthorizationModelNotFound

func AuthorizationModelNotFound(modelID string) error

func ConvertToEncodedErrorCode

func ConvertToEncodedErrorCode(statusError *status.Status) int32

func DuplicateTupleInWrite

func DuplicateTupleInWrite(tk tuple.TupleWithoutCondition) error

func ExceededEntityLimit

func ExceededEntityLimit(entity string, limit int) error

func HandleError

func HandleError(public string, err error) error

HandleError is used to surface some errors, and hide others. Use `public` if you want to return a useful error message to the user.

func HandleTupleValidateError

func HandleTupleValidateError(err error) error

HandleTupleValidateError provide common routines for handling tuples validation error

func InvalidAuthorizationModelInput

func InvalidAuthorizationModelInput(err error) error

func IsValidEncodedError

func IsValidEncodedError(errorCode int32) bool

IsValidEncodedError returns whether the error code is a valid encoded error

func LatestAuthorizationModelNotFound

func LatestAuthorizationModelNotFound(store string) error

func RelationNotFound

func RelationNotFound(relation string, objectType string, tk *openfgav1.TupleKey) error

func TypeNotFound

func TypeNotFound(objectType string) error

func ValidationError

func ValidationError(cause error) error

func WriteFailedDueToInvalidInput

func WriteFailedDueToInvalidInput(err error) error

Types

type EncodedError

type EncodedError struct {
	HTTPStatusCode int
	GRPCStatusCode codes.Code
	ActualError    ErrorResponse
}

EncodedError allows customized error with code in string and specified http status field

func NewEncodedError

func NewEncodedError(errorCode int32, message string) *EncodedError

NewEncodedError returns the encoded error with the correct http status code etc.

func (*EncodedError) Code

func (e *EncodedError) Code() string

Code returns the encoded code in string

func (*EncodedError) CodeValue

func (e *EncodedError) CodeValue() int32

CodeValue returns the encoded code in integer

func (*EncodedError) Error

func (e *EncodedError) Error() string

Error returns the encoded message

func (*EncodedError) GRPCStatus

func (e *EncodedError) GRPCStatus() *status.Status

func (*EncodedError) HTTPStatus

func (e *EncodedError) HTTPStatus() int

HTTPStatus returns the HTTP Status code

type ErrorResponse

type ErrorResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

type InternalError

type InternalError struct {
	// contains filtered or unexported fields
}

func NewInternalError

func NewInternalError(public string, internal error) InternalError

NewInternalError returns an error that is decorated with a public-facing error message. It is only meant to be called by HandleError.

func (InternalError) Error

func (e InternalError) Error() string

func (InternalError) Internal

func (e InternalError) Internal() error

func (InternalError) InternalError

func (e InternalError) InternalError() string

func (InternalError) Is

func (e InternalError) Is(target error) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL