sharedmodels

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CelitechError

type CelitechError[T any] struct {
	Err      error
	Data     *T
	Body     []byte
	Raw      *http.Response
	Metadata CelitechErrorMetadata
}

CelitechError wraps API errors with detailed metadata including status code, headers, and raw response. It implements the error interface and provides structured access to error information.

func NewCelitechError

func NewCelitechError[T any](transportError *httptransport.ErrorResponse[T]) *CelitechError[T]

NewCelitechError creates a new CelitechError from an internal transport error. It extracts error details, body, status code, and headers into a user-facing error structure.

func (*CelitechError[T]) Error

func (e *CelitechError[T]) Error() string

Error implements the error interface, returning the error message string.

func (*CelitechError[T]) GetBody

func (e *CelitechError[T]) GetBody() []byte

GetBody returns the raw response body bytes from the error response. Returns nil if no response body was received.

func (*CelitechError[T]) GetData

func (e *CelitechError[T]) GetData() *T

GetData returns the deserialized error response data. Returns nil if unmarshaling failed or the response body was empty.

func (*CelitechError[T]) Unwrap

func (e *CelitechError[T]) Unwrap() error

Unwrap returns the underlying error, enabling errors.Is and errors.As to traverse the chain.

type CelitechErrorMetadata

type CelitechErrorMetadata struct {
	Headers    map[string]string
	StatusCode int
}

CelitechErrorMetadata contains HTTP metadata associated with an error response.

type CelitechResponse

type CelitechResponse[T any] struct {
	Data     T
	Raw      *http.Response
	Metadata CelitechResponseMetadata
}

CelitechResponse is the user-facing wrapper for API responses. It contains the deserialized data, raw HTTP response, and metadata like headers and status code.

func NewCelitechResponse

func NewCelitechResponse[T any](resp *httptransport.Response[T]) *CelitechResponse[T]

NewCelitechResponse creates a new response wrapper from an internal transport response. Extracts data and metadata into a user-facing structure.

func (*CelitechResponse[T]) GetData

func (r *CelitechResponse[T]) GetData() T

GetData returns the deserialized response data.

func (CelitechResponse[T]) String

func (r CelitechResponse[T]) String() string

String returns a JSON representation of the response for debugging. Returns an error message if JSON marshaling fails.

type CelitechResponseMetadata

type CelitechResponseMetadata struct {
	Headers    map[string]string
	StatusCode int
}

CelitechResponseMetadata contains HTTP metadata from the API response. Includes status code and headers for inspection and debugging.

Jump to

Keyboard shortcuts

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