mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* Move all public connectors to ce/plugins * Update tooling to account for new go modules under ce * Ensure we test all CE plugins in CI * Move Dummypay to ce/plugins for simplicity's sake in the generation scripts * Use versioned pkg/domain in plugins * Ensure that renovate updates all CE plugins in a single PR when pkg/domain tags are pushed to github * Ensure Justfile commands work over all CE plugins * Copy ce plugin go.mods in dev.Dockerfile * Only add a go.mod for new plugins if they are ce * Ensure generated generic client structs are named correctly for submodule * Add coverprofile for each ce plugin * Add set -e for Justfile for loops over plugins * Infer go version from flake.nix in connector template tool
42 lines
897 B
Go
42 lines
897 B
Go
package client
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type qontoErrors struct {
|
|
StatusCode int `json:"-"`
|
|
Errors []qontoError
|
|
}
|
|
|
|
type qontoError struct {
|
|
Code string `json:"code"`
|
|
Detail string `json:"detail"`
|
|
}
|
|
|
|
func (errorResponse qontoErrors) Error() error {
|
|
var err error
|
|
if len(errorResponse.Errors) == 0 {
|
|
err = fmt.Errorf("statusCode=%d, errorMessage=\"unexpected error\"", errorResponse.StatusCode)
|
|
return err
|
|
}
|
|
|
|
if len(errorResponse.Errors) == 1 {
|
|
me := errorResponse.Errors[0]
|
|
return fmt.Errorf(
|
|
"statusCode=%d, errorCode=\"%s\", errorMessage=\"%s\"",
|
|
errorResponse.StatusCode,
|
|
me.Code,
|
|
me.Detail,
|
|
)
|
|
}
|
|
|
|
errMsg := fmt.Sprintf("multiple errors (statusCode=%d):", errorResponse.StatusCode)
|
|
for _, e := range errorResponse.Errors {
|
|
errMsg += fmt.Sprintf(" [errorCode=\"%s\", errorMessage=\"%s\"]", e.Code, e.Detail)
|
|
}
|
|
err = errors.New(errMsg)
|
|
return err
|
|
}
|