From a1420bfd2bb4eb04006e46dfcf682ece86459749 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Fri, 11 Feb 2022 16:20:08 +0100 Subject: 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 --- src/error.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/error.go (limited to 'src/error.go') 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 +} -- cgit v1.2.3