generated from axone-protocol/template-oss
-
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.
feat(dataverse): handle more properly errors
- Loading branch information
Showing
3 changed files
with
38 additions
and
7 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
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
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,30 @@ | ||
package dataverse | ||
|
||
import "fmt" | ||
|
||
type MessageError string | ||
|
||
const ( | ||
ErrNoResult MessageError = "no result found in binding" | ||
ErrVarNotFound MessageError = "variable not found in binding result" | ||
ErrType MessageError = "variable result type mismatch in binding result" | ||
) | ||
|
||
type DVError struct { | ||
message MessageError | ||
detail error | ||
} | ||
|
||
func (e *DVError) Error() string { | ||
if e.detail == nil { | ||
return fmt.Sprintf("%v", e.message) | ||
} | ||
return fmt.Sprintf("%v: %v", e.message, e.detail) | ||
} | ||
|
||
func NewDVError(message MessageError, detail error) error { | ||
return &DVError{ | ||
message: message, | ||
detail: detail, | ||
} | ||
} |