2016-02-03 21:54:02 +00:00
// Package common contains common utilities that are shared among other packages.
// See each sub-package for detail.
package common
2016-03-09 23:33:01 +00:00
2018-10-11 18:43:37 +00:00
import "v2ray.com/core/common/errors"
2018-09-30 21:08:41 +00:00
//go:generate errorgen
2017-04-08 23:43:25 +00:00
2018-10-11 18:43:37 +00:00
var (
// ErrNoClue is for the situation that existing information is not enough to make a decision. For example, Router may return this error when there is no suitable route.
ErrNoClue = errors . New ( "not enough information for making a decision" )
)
2016-12-27 23:53:29 +00:00
// Must panics if err is not nil.
func Must ( err error ) {
if err != nil {
panic ( err )
}
}
2017-09-19 21:27:49 +00:00
2018-02-21 20:42:33 +00:00
// Must2 panics if the second parameter is not nil, otherwise returns the first parameter.
func Must2 ( v interface { } , err error ) interface { } {
Must ( err )
return v
2017-09-19 21:27:49 +00:00
}
2018-04-11 14:15:29 +00:00
// Error2 returns the err from the 2nd parameter.
func Error2 ( v interface { } , err error ) error {
return err
}