package errors

import "github.com/open-policy-agent/opa/internal/wasm/sdk/opa/errors"

Index

Constants

const (
	// InvalidConfigErr is the error code returned if the OPA initialization fails due to an invalid config.
	InvalidConfigErr string = "invalid_config"

	// InvalidPolicyOrDataErr is the error code returned if either policy or data is invalid.
	InvalidPolicyOrDataErr string = "invalid_policy_or_data"

	// InvalidBundleErr is the error code returned if the bundle loaded is corrupted.
	InvalidBundleErr string = "invalid_bundle"

	// NotReadyErr is the error code returned if the OPA instance is not initialized.
	NotReadyErr string = "not_ready"

	// InternalErr is the error code returned if the evaluation fails due to an internal error.
	InternalErr string = "internal_error"

	// CancelledErr is the error code returned if the evaluation is cancelled.
	CancelledErr string = "cancelled"
)

Functions

func IsCancel

func IsCancel(err error) bool

IsCancel returns true if err was caused by cancellation.

func IsError

func IsError(err error) bool

IsError returns true if the err is an Error.

func New

func New(code, msg string) error

New returns a new error with the passed code

Types

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message,omitempty"`
}

Error is the error code type returned by the SDK functions when an error occurs.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is allows matching error types using errors.Is (see IsCancel).

Source Files

errors.go

Version
v1.4.2 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
6 hours ago

Tools for package owners.