mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-12-04 13:50:59 -06:00
28 lines
521 B
Go
28 lines
521 B
Go
package common
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrFrontendBadIndex = errors.New("incorrect connection index")
|
|
ErrBackendBusy = errors.New("backend is busy")
|
|
)
|
|
|
|
// ShouldNotError panics if the error is not nil.
|
|
func ShouldNotError(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// ShouldNotErrorUnless panics if the error is not nil and not in the allowed list.
|
|
func ShouldNotErrorUnless(err error, allowed ...error) {
|
|
if err != nil {
|
|
for _, a := range allowed {
|
|
if err == a {
|
|
return
|
|
}
|
|
}
|
|
panic(err)
|
|
}
|
|
}
|