From 524118c0e5bd6b2a67bee31888081b6e731d63df Mon Sep 17 00:00:00 2001 From: Laszlo Pusok <7979773+lpusok@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:05:37 +0200 Subject: [PATCH] Adding comments --- errorutil/hiddenerror.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/errorutil/hiddenerror.go b/errorutil/hiddenerror.go index 89ff2d6..85c9838 100644 --- a/errorutil/hiddenerror.go +++ b/errorutil/hiddenerror.go @@ -1,19 +1,25 @@ package errorutil +// HiddenOriginalError allows to include an error in the error chain but do not print it. +// this allows replacing it with a more readable error message, +// while allowing code to check for the type of the error type HiddenOriginalError struct { originalErr error } +// NewHiddenOriginalError ... func NewHiddenOriginalError(originalErr error) *HiddenOriginalError { return &HiddenOriginalError{ originalErr: originalErr, } } +// Error ... func (h HiddenOriginalError) Error() string { return "" } +// Unwrap ... func (h HiddenOriginalError) Unwrap() error { return h.originalErr }