mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-27 16:07:19 +02:00
zero: only leave public packages in pkg/zero (#4854)
This commit is contained in:
parent
a6ae9d3f2d
commit
b66634d1e6
24 changed files with 22 additions and 22 deletions
44
internal/zero/apierror/terminal.go
Normal file
44
internal/zero/apierror/terminal.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package apierror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// terminalError is an error that should not be retried
|
||||
type terminalError struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
// Error implements error for terminalError
|
||||
func (e *terminalError) Error() string {
|
||||
return fmt.Sprintf("terminal error: %v", e.Err)
|
||||
}
|
||||
|
||||
// Unwrap implements errors.Unwrap for terminalError
|
||||
func (e *terminalError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
// Is implements errors.Is for terminalError
|
||||
func (e *terminalError) Is(err error) bool {
|
||||
//nolint:errorlint
|
||||
_, ok := err.(*terminalError)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (e *terminalError) IsTerminal() {}
|
||||
|
||||
// NewTerminalError creates a new terminal error that cannot be retried
|
||||
func NewTerminalError(err error) error {
|
||||
return &terminalError{Err: err}
|
||||
}
|
||||
|
||||
// IsTerminalError returns true if the error is a terminal error
|
||||
func IsTerminalError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var te *terminalError
|
||||
return errors.As(err, &te)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue