error.go raw
1 package v2
2
3 import (
4 "errors"
5 "fmt"
6 )
7
8 var (
9 ErrInvalidRequestObj = errors.New("failed to build request")
10 ErrNotFound = errors.New("object not found")
11 )
12
13 type (
14 BadResponseError struct {
15 ErrorMsg string `json:"error,omitempty"` //nolint: tagliatelle
16 Description string `json:"description,omitempty"`
17 Location string `json:"location,omitempty"`
18 Code int `json:"code"`
19 }
20 )
21
22 func (e BadResponseError) Error() string {
23 err := fmt.Sprintf("error response: %v.", e.ErrorMsg)
24 if e.Description != "" {
25 err += fmt.Sprintf(" Description: %v.", e.Description)
26 }
27 if e.Location != "" {
28 err += fmt.Sprintf(" Location: %v.", e.Location)
29 }
30
31 return err
32 }
33