summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2023-02-17 10:35:27 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2023-02-17 10:35:27 +0100
commitb05ce93edfeb86ddd7af5a859eb5e20b3653e56b (patch)
tree163c8d01e96be782eaa9b066639de34e4e03f981 /internal
parent354706c76e0531a282d1ee904ec5a0640ab34627 (diff)
Refactor: Improve some errors by using errors.New and add context
Diffstat (limited to 'internal')
-rw-r--r--internal/oauth/oauth.go4
-rw-r--r--internal/server/custom.go2
-rw-r--r--internal/server/instituteaccess.go4
-rw-r--r--internal/server/server.go2
4 files changed, 6 insertions, 6 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go
index 6b42bc2..cb060c4 100644
--- a/internal/oauth/oauth.go
+++ b/internal/oauth/oauth.go
@@ -153,7 +153,7 @@ func (oauth *OAuth) setupListener() error {
// If it was unsuccessful it returns an error.
func (oauth *OAuth) tokensWithCallback() error {
if oauth.session.Listener == nil {
- return errors.Errorf("failed getting tokens with callback: no listener")
+ return errors.New("failed getting tokens with callback: no listener")
}
mux := http.NewServeMux()
// server /callback over the listener address
@@ -434,7 +434,7 @@ func (oauth *OAuth) Init(iss string, baseAuthorizationURL string, tokenURL strin
// It returns the port as an integer and an error if there is any.
func (oauth *OAuth) ListenerPort() (int, error) {
if oauth.session.Listener == nil {
- return 0, errors.Errorf("failed to get listener port")
+ return 0, errors.New("failed to get listener port")
}
return oauth.session.Listener.Addr().(*net.TCPAddr).Port, nil
}
diff --git a/internal/server/custom.go b/internal/server/custom.go
index bf0b230..0d78308 100644
--- a/internal/server/custom.go
+++ b/internal/server/custom.go
@@ -18,7 +18,7 @@ func (ss *Servers) SetCustomServer(server Server) error {
ss.CustomServers.CurrentURL = b.URL
ss.IsType = CustomServerType
} else {
- return errors.Errorf("not a custom server")
+ return errors.Errorf("this server is not yet added as a custom server: %s", b.URL)
}
return nil
}
diff --git a/internal/server/instituteaccess.go b/internal/server/instituteaccess.go
index 56ed1cf..050e721 100644
--- a/internal/server/instituteaccess.go
+++ b/internal/server/instituteaccess.go
@@ -25,14 +25,14 @@ func (ss *Servers) SetInstituteAccess(srv Server) error {
}
if b.Type != "institute_access" {
- return errors.Errorf("not an institute access server")
+ return errors.Errorf("not an institute access server, url: %s, type: %s", b.URL, b.Type)
}
if _, ok := ss.InstituteServers.Map[b.URL]; ok {
ss.InstituteServers.CurrentURL = b.URL
ss.IsType = InstituteAccessServerType
} else {
- return errors.Errorf("no such institute access server")
+ return errors.Errorf("institute access server with url: %s, is not yet configured", b.URL)
}
return nil
}
diff --git a/internal/server/server.go b/internal/server/server.go
index ef02612..daaa7a6 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -294,7 +294,7 @@ func Config(server Server, wireguardSupport bool, preferTCP bool) (*ConfigData,
cfg, err = openVPNGetConfig(server, preferTCP)
// The config supports no available protocol because the profile only supports WireGuard but the client doesn't
default:
- return nil, errors.Errorf("no supported protocol found")
+ return nil, errors.New("no supported protocol found")
}
// Add script security 0 to disable OpenVPN scripts