-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5751d5d
commit 660e3b6
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package utilities | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type MarshalError struct { | ||
structName string | ||
innerError error | ||
} | ||
|
||
func NewMarshalError(structName string, err error) MarshalError { | ||
return MarshalError{ | ||
structName: structName, | ||
innerError: err, | ||
} | ||
} | ||
|
||
// Error implements the Error method for the error interface. | ||
// It returns a string representation of the ApiError instance when used in an error context. | ||
func (a MarshalError) Error() string { | ||
indent := "\n\t=>" | ||
switch a.innerError.(type) { | ||
case MarshalError: | ||
indent = "." | ||
} | ||
return fmt.Sprintf("%v %v %v", a.structName, indent, a.innerError) | ||
} |