-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patherror.go
65 lines (49 loc) · 1.1 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
package main
import (
"fmt"
"github.com/stripe/stripe-go"
"net/http"
)
type SubscriptionRequired struct {
}
func (e *SubscriptionRequired) Code() string {
return "subscription_required"
}
func (e *SubscriptionRequired) Error() string {
return fmt.Sprintf("%s", e.Code())
}
func (e *SubscriptionRequired) Status() int {
return http.StatusForbidden
}
func (e *SubscriptionRequired) Message() string {
return http.StatusText(e.Status())
}
type InvalidReceipt struct {
}
func (e *InvalidReceipt) Code() string {
return "invalid_receipt"
}
func (e *InvalidReceipt) Error() string {
return fmt.Sprintf("%s", e.Code())
}
func (e *InvalidReceipt) Status() int {
return http.StatusBadRequest
}
func (e *InvalidReceipt) Message() string {
return http.StatusText(e.Status())
}
type StripeError struct {
Err *stripe.Error
}
func (e *StripeError) Code() string {
return string(e.Err.Code)
}
func (e *StripeError) Error() string {
return fmt.Sprintf("%s - %s", e.Code(), e.Err)
}
func (e *StripeError) Status() int {
return e.Err.HTTPStatusCode
}
func (e *StripeError) Message() string {
return e.Err.Msg
}