Files
onspring-api-sdk-go/error.go
T
Stevan Freeborn a9e49906e0 feat: initialize client core and ping endpoint
establishes the foundational architecture for the Onspring Go SDK.

changes included:
- add `Client` struct and `NewClient` constructor with authentication.
- implement functional options pattern (WithHTTPClient, WithBaseURL, etc.).
- add `OnspringAPIError` type for handling non-2xx responses.
- implement internal request construction and execution logic.
- add `Ping` service for API health check verification.
- add comprehensive unit tests and mock server infrastructure.
2025-12-05 21:33:23 -06:00

25 lines
843 B
Go

package onspring
import (
"fmt"
)
// OnspringAPIError represents an error returned by the Onspring API.
// It contains the HTTP status code and the error message from the API response.
// This error type implements the error interface.
type OnspringAPIError struct {
// StatusCode is the HTTP status code returned by the API.
StatusCode int
// Message is the error message returned by the API or the HTTP status text.
Message string
}
// Error returns a formatted error string containing the status code and message.
// It implements the error interface for OnspringAPIError.
//
// Returns:
// - string: A formatted error message in the format "onspring api error: status={code} message={message}"
func (e *OnspringAPIError) Error() string {
return fmt.Sprintf("onspring api error: status=%d message=%s", e.StatusCode, e.Message)
}