types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package types contains shared types for the Salesforce SDK to avoid import cycles.

Index

Constants

View Source
const (
	DefaultAPIVersion = "59.0"
	DefaultTimeout    = 30 * time.Second
	DefaultMaxRetries = 3
)

Version constants

Variables

This section is empty.

Functions

func IsAuthError

func IsAuthError(err error) bool

IsAuthError checks if the error is an authentication error.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if the error is a 404 not found error.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError checks if the error is a rate limit error.

func ParseAPIError

func ParseAPIError(statusCode int, body []byte) error

ParseAPIError parses an API error from the response body.

Types

type APIError

type APIError struct {
	Message    string            `json:"message"`
	ErrorCode  ErrorCode         `json:"errorCode"`
	Fields     []string          `json:"fields,omitempty"`
	StatusCode int               `json:"-"`
	Raw        []byte            `json:"-"`
	Details    map[string]string `json:"extended,omitempty"`
}

APIError represents an error returned by the Salesforce API.

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface.

func (*APIError) IsRetryable

func (e *APIError) IsRetryable() bool

IsRetryable checks if the request should be retried.

func (*APIError) IsSessionInvalid

func (e *APIError) IsSessionInvalid() bool

IsSessionInvalid checks if the error is due to an invalid or expired session.

type APIErrors

type APIErrors []APIError

APIErrors represents multiple API errors.

func (APIErrors) Error

func (e APIErrors) Error() string

Error implements the error interface.

func (APIErrors) First

func (e APIErrors) First() *APIError

First returns the first error or nil if empty.

type AuthError

type AuthError struct {
	ErrorType   string `json:"error"`
	Description string `json:"error_description"`
	StatusCode  int    `json:"-"`
}

AuthError represents an authentication error.

func (*AuthError) Error

func (e *AuthError) Error() string

Error implements the error interface.

func (*AuthError) IsInvalidGrant

func (e *AuthError) IsInvalidGrant() bool

IsInvalidGrant checks if the error is due to an invalid grant.

type ErrorCode

type ErrorCode string

ErrorCode represents a Salesforce error code.

const (
	ErrorCodeInvalidSession       ErrorCode = "INVALID_SESSION_ID"
	ErrorCodeSessionExpired       ErrorCode = "SESSION_EXPIRED"
	ErrorCodeInvalidField         ErrorCode = "INVALID_FIELD"
	ErrorCodeMalformedQuery       ErrorCode = "MALFORMED_QUERY"
	ErrorCodeInvalidType          ErrorCode = "INVALID_TYPE"
	ErrorCodeEntityDeleted        ErrorCode = "ENTITY_IS_DELETED"
	ErrorCodeDuplicateValue       ErrorCode = "DUPLICATE_VALUE"
	ErrorCodeRequiredFieldMissing ErrorCode = "REQUIRED_FIELD_MISSING"
	ErrorCodeInvalidCrossRef      ErrorCode = "INVALID_CROSS_REFERENCE_KEY"
	ErrorCodeInsufficientAccess   ErrorCode = "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY"
	ErrorCodeRequestLimit         ErrorCode = "REQUEST_LIMIT_EXCEEDED"
	ErrorCodeStorageLimit         ErrorCode = "STORAGE_LIMIT_EXCEEDED"
)

Common Salesforce error codes

type Logger

type Logger interface {
	Debug(msg string, args ...interface{})
	Info(msg string, args ...interface{})
	Warn(msg string, args ...interface{})
	Error(msg string, args ...interface{})
}

Logger defines the interface for logging.

type RateLimitError

type RateLimitError struct {
	RetryAfter int
	Message    string
}

RateLimitError represents a rate limit exceeded error.

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

Error implements the error interface.

type Token

type Token struct {
	AccessToken  string
	TokenType    string
	RefreshToken string
	InstanceURL  string
	IssuedAt     time.Time
	ExpiresAt    time.Time
}

Token represents an authentication token.

func (*Token) IsExpired

func (t *Token) IsExpired() bool

IsExpired checks if the token has expired.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a client-side validation error.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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