apierror

package
v3.37.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package apierror provides the CLI's own error type for UpCloud API errors, independent of the SDK version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromResponse

func FromResponse(status int, body []byte) error

FromResponse converts an unsuccessful API response into a *Problem. It accepts problem+json and legacy error bodies.

func IsNotFound

func IsNotFound(err error) bool

Types

type InvalidParam

type InvalidParam struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

type Problem

type Problem struct {
	Type          string         `json:"type"`
	Title         string         `json:"title"`
	InvalidParams []InvalidParam `json:"invalid_params,omitempty"`
	CorrelationID string         `json:"correlation_id,omitempty"`
	Status        int            `json:"status"`
}

Problem is an UpCloud API error. Its Error and ErrorCode output match the v8 SDK's upcloud.Problem.

func (*Problem) Error

func (p *Problem) Error() string

func (*Problem) ErrorCode

func (p *Problem) ErrorCode() string

ErrorCode returns the error code, e.g. SERVICE_NOT_FOUND, also when Type is a documentation URL.

Jump to

Keyboard shortcuts

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