mirror of
https://github.com/raseels-repos/golang-saas-starter-kit.git
synced 2025-06-06 23:46:29 +02:00
29 lines
670 B
Go
29 lines
670 B
Go
package weberror
|
|
|
|
import "github.com/pkg/errors"
|
|
|
|
// shutdown is a type used to help with the graceful termination of the service.
|
|
type shutdown struct {
|
|
Message string
|
|
}
|
|
|
|
// Error is the implementation of the error interface.
|
|
func (s *shutdown) Error() string {
|
|
return s.Message
|
|
}
|
|
|
|
// NewShutdownError returns an error that causes the framework to signal
|
|
// a graceful shutdown.
|
|
func NewShutdownError(message string) error {
|
|
return &shutdown{message}
|
|
}
|
|
|
|
// IsShutdown checks to see if the shutdown error is contained
|
|
// in the specified error value.
|
|
func IsShutdown(err error) bool {
|
|
if _, ok := errors.Cause(err).(*shutdown); ok {
|
|
return true
|
|
}
|
|
return false
|
|
}
|