diff options
Diffstat (limited to 'errors.go')
| -rw-r--r-- | errors.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..989561a --- /dev/null +++ b/errors.go @@ -0,0 +1,46 @@ +// Copyright 2021, Shulhan <ms@kilabit.info>. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package trunks + +import ( + "fmt" + "net/http" + + liberrors "github.com/shuLhan/share/lib/errors" + libhttp "github.com/shuLhan/share/lib/http" +) + +func errInternal(err error) error { + res := &libhttp.EndpointResponse{ + E: liberrors.E{ + Code: http.StatusInternalServerError, + Message: err.Error(), + Name: "ERR_INTERNAL", + }, + } + return res +} + +func errInvalidTarget(id string) error { + res := &libhttp.EndpointResponse{ + E: liberrors.E{ + Code: http.StatusBadRequest, + Message: fmt.Sprintf("invalid or emtpy Target.ID: %q", id), + Name: "ERR_INVALID_TARGET", + }, + } + return res +} + +func errInvalidHttpTarget(id string) error { + res := &libhttp.EndpointResponse{ + E: liberrors.E{ + Code: http.StatusBadRequest, + Message: fmt.Sprintf("invalid or emtpy HttpTarget.ID: %q", id), + Name: "ERR_INVALID_HTTP_TARGET", + }, + } + return res +} |
