forked from pneymrl2f/nightingale
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
501 B
37 lines
501 B
package errors
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type PageError struct {
|
|
Message string
|
|
}
|
|
|
|
func (p PageError) Error() string {
|
|
return p.Message
|
|
}
|
|
|
|
func (p PageError) String() string {
|
|
return p.Message
|
|
}
|
|
|
|
func Bomb(format string, a ...interface{}) {
|
|
panic(PageError{Message: fmt.Sprintf(format, a...)})
|
|
}
|
|
|
|
func Dangerous(v interface{}) {
|
|
if v == nil {
|
|
return
|
|
}
|
|
|
|
switch t := v.(type) {
|
|
case string:
|
|
if t != "" {
|
|
panic(PageError{Message: t})
|
|
}
|
|
case error:
|
|
panic(PageError{Message: t.Error()})
|
|
}
|
|
}
|