-
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.
* fix cache * fix nil pointer * set gas factor * more logging * more * work * work * add recovery fn * changeout func
- Loading branch information
1 parent
3c2b0f6
commit 6e77828
Showing
4 changed files
with
44 additions
and
9 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
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,20 @@ | ||
package util | ||
|
||
import "fmt" | ||
|
||
func InterfaceToError(errorInterface interface{}) error { | ||
// Attempt to coerce into error | ||
err, ok := errorInterface.(error) | ||
if ok { | ||
return err | ||
} | ||
|
||
// Otherwise attempt to coerce into string | ||
stringifiedErr, ok := errorInterface.(string) | ||
if ok { | ||
return fmt.Errorf(stringifiedErr) | ||
} | ||
|
||
// Otherwise, just ditch with a generic error. | ||
return fmt.Errorf("recovered from a panic that was neither a string nor an error") | ||
} |