-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckout_error.go
More file actions
39 lines (33 loc) · 825 Bytes
/
checkout_error.go
File metadata and controls
39 lines (33 loc) · 825 Bytes
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
package picnic
import (
"fmt"
)
type CheckoutError struct {
Code string
Title string
Message string
ResolveKey string
Blocking bool
Err error
}
func (e *CheckoutError) Error() string {
return e.Err.Error()
}
func wrapCheckoutError(err error) *CheckoutError {
return &CheckoutError{
Err: err,
}
}
func (p *CheckoutError) IsAgeVerificationCheck() bool {
return p.Code == "LEGACY_ALCOHOL_AGE_VERIFICATION_REQUIRED"
}
func (p *PicnicError) CreateCheckoutError() *CheckoutError {
return &CheckoutError{
Code: p.Details.Type,
Title: p.Details.LocalizedTitle,
Message: p.Details.LocalizedMessage,
ResolveKey: p.Details.ResolveKey,
Blocking: p.Details.Blocking,
Err: fmt.Errorf("picnic-api: cart has an issue %s with message %s", p.Code, p.Message),
}
}