mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
35 lines
574 B
Go
35 lines
574 B
Go
package mailchimp
|
|
|
|
import "github.com/hanzoai/gochimp3"
|
|
|
|
type Error struct {
|
|
Unknown error
|
|
Mailchimp error
|
|
Status int
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
if e.Mailchimp != nil {
|
|
return e.Mailchimp.Error()
|
|
}
|
|
return e.Unknown.Error()
|
|
}
|
|
|
|
func wrapError(fn func() error) *Error {
|
|
// Do work
|
|
err := fn()
|
|
|
|
// Not an error
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
// Handle Mailchimp API Errors
|
|
if merr, ok := err.(*gochimp3.APIError); ok {
|
|
return &Error{Mailchimp: err, Status: merr.Status}
|
|
}
|
|
|
|
// Handle any other errors
|
|
return &Error{Unknown: err, Status: 500}
|
|
}
|