diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-02-11 16:20:08 +0100 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-04-05 12:26:11 +0200 |
| commit | a1420bfd2bb4eb04006e46dfcf682ece86459749 (patch) | |
| tree | 608d220aafb021fa372f576691c8f1bcedf07129 /src/error.go | |
| parent | 12a0a2700d64f99b8f14d03c8de1c1ea5e922eff (diff) | |
Abstract error types and remove JSON parsing
For now JSON parsing does not make a lot of sense. This is better off
handled by the clients for now.
Signed-off-by: jwijenbergh <jeroenwijenbergh@protonmail.com>
Diffstat (limited to 'src/error.go')
| -rw-r--r-- | src/error.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/error.go b/src/error.go new file mode 100644 index 0000000..87d7e53 --- /dev/null +++ b/src/error.go @@ -0,0 +1,30 @@ +package eduvpn + +type detailedVPNErrorCode int8 +type VPNErrorCode int8 + +type VPNError struct { + Code VPNErrorCode + Detailed detailedVPNError +} + +func (err VPNError) Error() string { + return err.Detailed.Error() +} + +func (err VPNError) Unwrap() error { + return err.Detailed +} + +type detailedVPNError struct { + Code detailedVPNErrorCode + Message string + Cause error +} + +func (err detailedVPNError) Error() string { + return err.Message +} +func (err detailedVPNError) Unwrap() error { + return err.Cause +} |
