2023-09-04 18:01:56 +00:00
|
|
|
package modules
|
|
|
|
|
|
|
|
type (
|
|
|
|
preparationError struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
frostFSInitError struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
businessLogicError struct {
|
|
|
|
err error
|
|
|
|
}
|
2023-11-16 11:39:58 +00:00
|
|
|
|
|
|
|
frostFSIDInitError struct {
|
|
|
|
err error
|
|
|
|
}
|
2024-06-27 09:23:13 +00:00
|
|
|
|
|
|
|
policyInitError struct {
|
|
|
|
err error
|
|
|
|
}
|
2023-09-04 18:01:56 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func wrapPreparationError(e error) error {
|
|
|
|
return preparationError{e}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e preparationError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
func wrapFrostFSInitError(e error) error {
|
|
|
|
return frostFSInitError{e}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e frostFSInitError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
func wrapBusinessLogicError(e error) error {
|
|
|
|
return businessLogicError{e}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e businessLogicError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
2023-11-16 11:39:58 +00:00
|
|
|
func wrapFrostFSIDInitError(e error) error {
|
|
|
|
return frostFSIDInitError{e}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e frostFSIDInitError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
2024-06-27 09:23:13 +00:00
|
|
|
func wrapPolicyInitError(e error) error {
|
|
|
|
return policyInitError{e}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e policyInitError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
2023-09-04 18:01:56 +00:00
|
|
|
// ExitCode picks corresponding error code depending on the type of error provided.
|
|
|
|
// Returns 1 if error type is unknown.
|
|
|
|
func ExitCode(e error) int {
|
|
|
|
switch e.(type) {
|
|
|
|
case preparationError:
|
|
|
|
return 2
|
|
|
|
case frostFSInitError:
|
|
|
|
return 3
|
|
|
|
case businessLogicError:
|
|
|
|
return 4
|
2023-11-16 11:39:58 +00:00
|
|
|
case frostFSIDInitError:
|
|
|
|
return 4
|
2024-06-27 09:23:13 +00:00
|
|
|
case policyInitError:
|
|
|
|
return 5
|
2023-09-04 18:01:56 +00:00
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|