diff options
Diffstat (limited to 'pkg/syserr/syserr.go')
-rw-r--r-- | pkg/syserr/syserr.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/syserr/syserr.go b/pkg/syserr/syserr.go index 6a66e23a2..dad83e80c 100644 --- a/pkg/syserr/syserr.go +++ b/pkg/syserr/syserr.go @@ -68,8 +68,21 @@ func New(message string, linuxTranslation *linux.Errno) *Error { return err } +// NewDynamic creates a new error with a dynamic error message and an errno +// translation. +// +// NewDynamic should only be used sparingly and not be used for static error +// messages. Errors with static error messages should be declared with New as +// global variables. +func NewDynamic(message string, linuxTranslation *linux.Errno) *Error { + return &Error{message: message, errno: linuxTranslation} +} + // NewWithoutTranslation creates a new Error. If translation is attempted on // the error, translation will fail. +// +// NewWithoutTranslation may be called at any time, but static errors should +// be declared as global variables and dynamic errors should be used sparingly. func NewWithoutTranslation(message string) *Error { return &Error{message: message, noTranslation: true} } |