Artem Tataurov
54e1c333a1
All checks were successful
/ DCO (pull_request) Successful in 1m9s
/ Vulncheck (pull_request) Successful in 5m17s
/ Builds (1.20) (pull_request) Successful in 2m1s
/ Builds (1.21) (pull_request) Successful in 7m18s
/ Lint (pull_request) Successful in 15m19s
/ Tests (1.20) (pull_request) Successful in 1m14s
/ Tests (1.21) (pull_request) Successful in 11m45s
Signed-off-by: Artem Tataurov <a.tataurov@yadro.com>
53 lines
882 B
Go
53 lines
882 B
Go
package modules
|
|
|
|
type (
|
|
preparationError struct {
|
|
err error
|
|
}
|
|
|
|
frostFSInitError struct {
|
|
err error
|
|
}
|
|
|
|
businessLogicError struct {
|
|
err error
|
|
}
|
|
)
|
|
|
|
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()
|
|
}
|
|
|
|
// 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
|
|
}
|
|
return 1
|
|
}
|