aboutsummaryrefslogtreecommitdiff
path: root/config/error.go
diff options
context:
space:
mode:
authorJulien Dessaux2021-04-05 17:52:31 +0200
committerJulien Dessaux2021-04-05 17:52:31 +0200
commit1ffc9c42054e208a01d3e70e6b6f3e1781e798f8 (patch)
tree721f202dcf46fb5e9c181013237e4da9d27f796a /config/error.go
parentReworked error handling for better and simpler tests (diff)
downloadtrains-1ffc9c42054e208a01d3e70e6b6f3e1781e798f8.tar.gz
trains-1ffc9c42054e208a01d3e70e6b6f3e1781e798f8.tar.bz2
trains-1ffc9c42054e208a01d3e70e6b6f3e1781e798f8.zip
Moved code around to conform best practices
Diffstat (limited to 'config/error.go')
-rw-r--r--config/error.go92
1 files changed, 0 insertions, 92 deletions
diff --git a/config/error.go b/config/error.go
deleted file mode 100644
index c49b6a9..0000000
--- a/config/error.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package config
-
-import "fmt"
-
-type ErrorType int
-
-// file open configuration file error
-type OpenError struct {
- path string
- err error
-}
-
-func (e *OpenError) Error() string {
- return fmt.Sprintf("Failed to open configuration file : %s", e.path)
-}
-func (e *OpenError) Unwrap() error { return e.err }
-
-func newOpenError(path string, err error) error {
- return &OpenError{
- path: path,
- err: err,
- }
-}
-
-// Yaml configuration file decoding error
-type DecodeError struct {
- path string
- err error
-}
-
-func (e *DecodeError) Error() string {
- return fmt.Sprintf("Failed to decode configuration file : %s", e.path)
-}
-func (e *DecodeError) Unwrap() error { return e.err }
-
-func newDecodeError(path string, err error) error {
- return &DecodeError{
- path: path,
- err: err,
- }
-}
-
-// Invalid address field error
-type InvalidAddressError struct {
- address string
- err error
-}
-
-func (e *InvalidAddressError) Error() string {
- return fmt.Sprintf("Invalid address %s : it must be a valid ipv4 address, ipv6 address, or resolvable name", e.address)
-}
-func (e *InvalidAddressError) Unwrap() error { return e.err }
-
-func newInvalidAddressError(address string, err error) error {
- return &InvalidAddressError{
- address: address,
- err: err,
- }
-}
-
-// Invalid port field error
-type InvalidPortError struct {
- port string
- err error
-}
-
-func (e *InvalidPortError) Error() string {
- return fmt.Sprintf("Invalid port %s : it must be a valid port number or tcp service name", e.port)
-}
-func (e *InvalidPortError) Unwrap() error { return e.err }
-
-func newInvalidPortError(port string, err error) error {
- return &InvalidPortError{
- port: port,
- err: err,
- }
-}
-
-// Invalid token field error
-type InvalidTokenError struct {
- token string
-}
-
-func (e *InvalidTokenError) Error() string {
- return fmt.Sprintf("Invalid token %s : it must be an hexadecimal string that lookslike 12345678-9abc-def0-1234-56789abcdef0", e.token)
-}
-
-func newInvalidTokenError(token string) error {
- return &InvalidTokenError{
- token: token,
- }
-}