summaryrefslogtreecommitdiff
path: root/i18nerr/i18nerr.go
diff options
context:
space:
mode:
Diffstat (limited to 'i18nerr/i18nerr.go')
-rw-r--r--i18nerr/i18nerr.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/i18nerr/i18nerr.go b/i18nerr/i18nerr.go
index 3520ecc..d513fdd 100644
--- a/i18nerr/i18nerr.go
+++ b/i18nerr/i18nerr.go
@@ -4,6 +4,7 @@ package i18nerr
import (
"context"
"errors"
+ "fmt"
"sync"
"github.com/eduvpn/eduvpn-common/internal/log"
@@ -135,6 +136,26 @@ func Wrapf(err error, key message.Reference, args ...interface{}) *Error {
return &Error{key: key, args: args, wrapped: &Error{key: t, Misc: misc}, Misc: misc}
}
+// NewInternalf creates an internal localised error from a display string
+func NewInternal(disp string) *Error {
+ return Wrap(errors.New(disp), "An internal error occurred")
+}
+
+// NewInternalf creates an internal localised error from a display string and arguments
+func NewInternalf(disp string, args...interface{}) *Error {
+ return NewInternal(fmt.Sprintf(disp, args...))
+}
+
+// WrapInternal wraps an error and a display string into a localised internal error
+func WrapInternal(err error, disp string) *Error {
+ return NewInternal(fmt.Sprintf("%s with internal cause: %v", disp, err))
+}
+
+// WrapInternalf wraps an error and a display string with args into a localised internal error
+func WrapInternalf(err error, disp string, args ...interface{}) *Error {
+ return WrapInternal(err, fmt.Sprintf(disp, args...))
+}
+
// initializeLangs initializes the printers from the default catalog into the sync map
// we cannot do this in init() because this is too early
func inititializeLangs() {