jsonerror

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

README

HTTP JSON Error Schema

The error.proto represents the HTTP-JSON schema used by Google APIs to convey error payloads as described by https://cloud.google.com/apis/design/errors#http_mapping. This package is for internal parsing logic only and should not be used in any other context.

Regeneration

To regenerate the protobuf Go code you will need the following:

From this directory run the following command:

protoc -I $GOOGLEAPIS -I. --go_out=. --go_opt=module=github.com/googleapis/gax-go/v2/apierror/internal/proto error.proto
goimports -w .

Note: the module plugin option ensures the generated code is placed in this directory, and not in several nested directories defined by go_package option.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CustomError_CustomErrorCode_name = map[int32]string{
		0: "CUSTOM_ERROR_CODE_UNSPECIFIED",
		1: "TOO_MANY_FOO",
		2: "NOT_ENOUGH_FOO",
		3: "UNIVERSE_WAS_DESTROYED",
	}
	CustomError_CustomErrorCode_value = map[string]int32{
		"CUSTOM_ERROR_CODE_UNSPECIFIED": 0,
		"TOO_MANY_FOO":                  1,
		"NOT_ENOUGH_FOO":                2,
		"UNIVERSE_WAS_DESTROYED":        3,
	}
)

Enum value maps for CustomError_CustomErrorCode.

View Source
var File_apierror_internal_proto_error_proto protoreflect.FileDescriptor
View Source
var File_custom_error_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CustomError added in v2.5.1

type CustomError struct {

	// Error code specific to the custom API being invoked.
	Code CustomError_CustomErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=error.CustomError_CustomErrorCode" json:"code,omitempty"`
	// Name of the failed entity.
	Entity string `protobuf:"bytes,2,opt,name=entity,proto3" json:"entity,omitempty"`
	// Message that describes the error.
	ErrorMessage string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"`
	// contains filtered or unexported fields
}

CustomError is an example of a custom error message which may be included in an rpc status. It is not meant to reflect a standard error.

func (*CustomError) Descriptor deprecated added in v2.5.1

func (*CustomError) Descriptor() ([]byte, []int)

Deprecated: Use CustomError.ProtoReflect.Descriptor instead.

func (*CustomError) GetCode added in v2.5.1

func (*CustomError) GetEntity added in v2.5.1

func (x *CustomError) GetEntity() string

func (*CustomError) GetErrorMessage added in v2.5.1

func (x *CustomError) GetErrorMessage() string

func (*CustomError) ProtoMessage added in v2.5.1

func (*CustomError) ProtoMessage()

func (*CustomError) ProtoReflect added in v2.5.1

func (x *CustomError) ProtoReflect() protoreflect.Message

func (*CustomError) Reset added in v2.5.1

func (x *CustomError) Reset()

func (*CustomError) String added in v2.5.1

func (x *CustomError) String() string

type CustomError_CustomErrorCode added in v2.5.1

type CustomError_CustomErrorCode int32

Error code for `CustomError`.

const (
	// Default error.
	CustomError_CUSTOM_ERROR_CODE_UNSPECIFIED CustomError_CustomErrorCode = 0
	// Too many foo.
	CustomError_TOO_MANY_FOO CustomError_CustomErrorCode = 1
	// Not enough foo.
	CustomError_NOT_ENOUGH_FOO CustomError_CustomErrorCode = 2
	// Catastrophic error.
	CustomError_UNIVERSE_WAS_DESTROYED CustomError_CustomErrorCode = 3
)

func (CustomError_CustomErrorCode) Descriptor added in v2.5.1

func (CustomError_CustomErrorCode) Enum added in v2.5.1

func (CustomError_CustomErrorCode) EnumDescriptor deprecated added in v2.5.1

func (CustomError_CustomErrorCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use CustomError_CustomErrorCode.Descriptor instead.

func (CustomError_CustomErrorCode) Number added in v2.5.1

func (CustomError_CustomErrorCode) String added in v2.5.1

func (CustomError_CustomErrorCode) Type added in v2.5.1

type Error

type Error struct {

	// The actual error payload. The nested message structure is for backward
	// compatibility with Google API client libraries. It also makes the error
	// more readable to developers.
	Error *Error_Status `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

The error format v2 for Google JSON REST APIs. Copied from https://cloud.google.com/apis/design/errors#http_mapping.

NOTE: This schema is not used for other wire protocols.

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) GetError

func (x *Error) GetError() *Error_Status

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type Error_Status

type Error_Status struct {

	// The HTTP status code that corresponds to `google.rpc.Status.code`.
	Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	// This corresponds to `google.rpc.Status.message`.
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// This is the enum version for `google.rpc.Status.code`.
	Status code.Code `protobuf:"varint,4,opt,name=status,proto3,enum=google.rpc.Code" json:"status,omitempty"`
	// This corresponds to `google.rpc.Status.details`.
	Details []*anypb.Any `protobuf:"bytes,5,rep,name=details,proto3" json:"details,omitempty"`
	// contains filtered or unexported fields
}

This message has the same semantics as `google.rpc.Status`. It uses HTTP status code instead of gRPC status code. It has an extra field `status` for backward compatibility with Google API Client Libraries.

func (*Error_Status) Descriptor deprecated

func (*Error_Status) Descriptor() ([]byte, []int)

Deprecated: Use Error_Status.ProtoReflect.Descriptor instead.

func (*Error_Status) GetCode

func (x *Error_Status) GetCode() int32

func (*Error_Status) GetDetails

func (x *Error_Status) GetDetails() []*anypb.Any

func (*Error_Status) GetMessage

func (x *Error_Status) GetMessage() string

func (*Error_Status) GetStatus

func (x *Error_Status) GetStatus() code.Code

func (*Error_Status) ProtoMessage

func (*Error_Status) ProtoMessage()

func (*Error_Status) ProtoReflect

func (x *Error_Status) ProtoReflect() protoreflect.Message

func (*Error_Status) Reset

func (x *Error_Status) Reset()

func (*Error_Status) String

func (x *Error_Status) String() string

Jump to

Keyboard shortcuts

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