forked from TrueCloudLab/frostfs-s3-gw
67 lines
1.1 KiB
Go
67 lines
1.1 KiB
Go
package modules
|
|
|
|
type (
|
|
preparationError struct {
|
|
err error
|
|
}
|
|
|
|
frostFSInitError struct {
|
|
err error
|
|
}
|
|
|
|
businessLogicError struct {
|
|
err error
|
|
}
|
|
|
|
frostFSIDInitError 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()
|
|
}
|
|
|
|
func wrapFrostFSIDInitError(e error) error {
|
|
return frostFSIDInitError{e}
|
|
}
|
|
|
|
func (e frostFSIDInitError) 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
|
|
case frostFSIDInitError:
|
|
return 4
|
|
}
|
|
return 1
|
|
}
|