aboutsummaryrefslogtreecommitdiff
path: root/lib/errors/errors.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-05-09 21:54:02 +0700
committerShulhan <ms@kilabit.info>2022-05-09 21:54:02 +0700
commit0c9abc1a962955dd0b795a422958c5445145d54c (patch)
tree4bf0369f6469a7c22057a2840c9b1c56de460559 /lib/errors/errors.go
parentc833f34b716b3aeacfca8f92227ff04cad5d04ae (diff)
downloadpakakeh.go-0c9abc1a962955dd0b795a422958c5445145d54c.tar.xz
all: reformat all codes using gofmt 1.19 (the Go tip)
Diffstat (limited to 'lib/errors/errors.go')
-rw-r--r--lib/errors/errors.go12
1 files changed, 0 insertions, 12 deletions
diff --git a/lib/errors/errors.go b/lib/errors/errors.go
index b9a5b9bd..c76b764c 100644
--- a/lib/errors/errors.go
+++ b/lib/errors/errors.go
@@ -10,7 +10,6 @@ import (
"reflect"
)
-//
// E define custom error that wrap underlying error with custom code, message,
// and name.
//
@@ -20,7 +19,6 @@ import (
// The Name field is optional, intended to be consumed by program, for
// example, to provide a key as translation of Message into user's locale
// defined language.
-//
type E struct {
Code int `json:"code,omitempty"`
Message string `json:"message,omitempty"`
@@ -28,9 +26,7 @@ type E struct {
err error
}
-//
// Internal define an error caused by server.
-//
func Internal(err error) *E {
return &E{
Code: http.StatusInternalServerError,
@@ -40,9 +36,7 @@ func Internal(err error) *E {
}
}
-//
// InvalidInput generate an error for invalid input.
-//
func InvalidInput(field string) *E {
return &E{
Code: http.StatusBadRequest,
@@ -51,16 +45,12 @@ func InvalidInput(field string) *E {
}
}
-//
// Error implement the error interface.
-//
func (e *E) Error() string {
return e.Message
}
-//
// As set the target to e only if only target is **E.
-//
func (e *E) As(target interface{}) bool {
_, ok := target.(**E)
if ok {
@@ -71,9 +61,7 @@ func (e *E) As(target interface{}) bool {
return false
}
-//
// Unwrap return the internal error.
-//
func (e *E) Unwrap() error {
return e.err
}