Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package merrors
|
||||
|
||||
import "strings"
|
||||
|
||||
// Reasons for organization provisioning outcomes. They travel to callers in
|
||||
// gRPC error details so every outcome stays distinguishable regardless of the
|
||||
// status code it shares with others.
|
||||
const (
|
||||
ReasonOrganizationProvisioningInProgress = "organization.provisioning_in_progress"
|
||||
ReasonOrganizationAlreadyActive = "organization.already_active"
|
||||
ReasonOrganizationProvisioningBlocked = "organization.provisioning_blocked"
|
||||
ReasonOrganizationOwnerMismatch = "organization.owner_mismatch"
|
||||
ReasonOrganizationNotOperatorProvisioned = "organization.not_operator_provisioned"
|
||||
)
|
||||
|
||||
// ErrOrganizationProvisioningInProgress means another attempt currently holds
|
||||
// the provisioning lease of the organization.
|
||||
var ErrOrganizationProvisioningInProgress = Define(ReasonOrganizationProvisioningInProgress)
|
||||
|
||||
// ErrOrganizationAlreadyActive means the organization finished provisioning already.
|
||||
var ErrOrganizationAlreadyActive = Define(ReasonOrganizationAlreadyActive)
|
||||
|
||||
// ErrOrganizationProvisioningBlocked means a failed signup compensated the
|
||||
// organization and it requires manual recovery before it can be activated.
|
||||
var ErrOrganizationProvisioningBlocked = Define(ReasonOrganizationProvisioningBlocked)
|
||||
|
||||
// ErrOrganizationOwnerMismatch means the organization is being provisioned for
|
||||
// a different account than the one supplied.
|
||||
var ErrOrganizationOwnerMismatch = Define(ReasonOrganizationOwnerMismatch)
|
||||
|
||||
// ErrOrganizationNotOperatorProvisioned means the organization was created through signup:
|
||||
// organizations created through general signup are never finished by someone in backoffice.
|
||||
var ErrOrganizationNotOperatorProvisioned = Define(ReasonOrganizationNotOperatorProvisioned)
|
||||
|
||||
func OrganizationProvisioningInProgress(msg string) error {
|
||||
return organizationError(ErrOrganizationProvisioningInProgress, ReasonOrganizationProvisioningInProgress, msg)
|
||||
}
|
||||
|
||||
func OrganizationAlreadyActive(msg string) error {
|
||||
return organizationError(ErrOrganizationAlreadyActive, ReasonOrganizationAlreadyActive, msg)
|
||||
}
|
||||
|
||||
func OrganizationProvisioningBlocked(msg string) error {
|
||||
return organizationError(ErrOrganizationProvisioningBlocked, ReasonOrganizationProvisioningBlocked, msg)
|
||||
}
|
||||
|
||||
func OrganizationOwnerMismatch(msg string) error {
|
||||
return organizationError(ErrOrganizationOwnerMismatch, ReasonOrganizationOwnerMismatch, msg)
|
||||
}
|
||||
|
||||
func OrganizationNotOperatorProvisioned(msg string) error {
|
||||
return organizationError(ErrOrganizationNotOperatorProvisioned, ReasonOrganizationNotOperatorProvisioned, msg)
|
||||
}
|
||||
|
||||
func organizationError(code error, reason, msg string) error {
|
||||
msg = strings.TrimSpace(msg)
|
||||
if msg == "" && code != nil {
|
||||
msg = code.Error()
|
||||
}
|
||||
return classifiedError{
|
||||
base: ErrDataConflict,
|
||||
code: code,
|
||||
msg: msg,
|
||||
reason: reason,
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user