-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.go
70 lines (54 loc) · 1.38 KB
/
error.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2019 RetailNext, Inc.
//
// Licensed under the BSD 3-Clause License (the "License");
// you may not use this file except in compliance with the License.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package easypost
import (
"encoding/json"
"fmt"
)
var (
paymentError PaymentRequiredError
unauthorizedError UnauthorizedError
)
type ErrorCode string
type UnauthorizedError struct{}
func (e UnauthorizedError) Error() string {
return "unauthorized error"
}
type PaymentRequiredError struct{}
func (e PaymentRequiredError) Error() string {
return "payment required"
}
type ProcessingError struct {
code string
msg string
details json.RawMessage
}
func (e ProcessingError) Error() string {
return e.msg
}
func (e ProcessingError) Details(target interface{}) error {
return json.Unmarshal(e.details, target)
}
type errorMessage struct {
Code string `json:"code"`
Message string `json:"message"`
FieldErrors json.RawMessage `json:"errors"`
}
type FieldError struct {
Field string `json:"field"`
Message string `json:"message"`
}
type ErrorResponse struct {
Error errorMessage `json:"error"`
}
type NotSupportedRecordError struct {
recordType RecordType
}
func (e NotSupportedRecordError) Error() string {
return fmt.Sprintf("not supported record: %s", e.recordType)
}