-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
34 lines (27 loc) · 821 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package acquiring
import (
"encoding/json"
"errors"
"fmt"
"github.com/FairyTale5571/go-mono/internal/api"
)
type ErrorBody struct {
ErrCode string `json:"errCode"`
ErrText string `json:"errText"`
}
func (e ErrorBody) Error() string {
return fmt.Sprintf("Code %s: %s", e.ErrCode, e.ErrText)
}
var (
// ErrFailedToParsePEMBlock failed to parse PEM block containing the open-api key
ErrFailedToParsePEMBlock = errors.New("failed to parse PEM block containing the open-api key")
// ErrFailedToParsePublicKey failed to parse open-api key
ErrFailedToParsePublicKey = errors.New("failed to parse open-api key")
)
var errorParser api.ErrorParserFunc = func(body []byte) error {
var errBody ErrorBody
if err := json.Unmarshal(body, &errBody); err != nil {
return err
}
return errors.New(errBody.Error())
}