diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-12 02:11:11 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-15 01:52:45 +0700 |
| commit | d30bfb7fa1c32984eaba8ad1cf744328812e02b9 (patch) | |
| tree | 316e089ac24694a3793ff92475be531ccd444b74 /errors.go | |
| download | gorankusu-d30bfb7fa1c32984eaba8ad1cf744328812e02b9.tar.xz | |
trunks: a module for testing HTTP services
Trunks is a library and HTTP service that provide web user interface
to test HTTP service, similar to Postman, and for load testing.
For the load testing we use vegeta [1] as the backend.
[1] https://github.com/tsenart/vegeta
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 +} |
