forked from denisenkom/go-mssqldb
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace panic with returning errors from key decryption providers (#155)
* Add context parameter to key provider interface * update error handling for AE key providers
- Loading branch information
1 parent
e51fa15
commit 670fd58
Showing
16 changed files
with
396 additions
and
172 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,39 @@ | ||
package aecmk | ||
|
||
import "fmt" | ||
|
||
// Operation specifies the action that returned an error | ||
type Operation int | ||
|
||
const ( | ||
Decryption Operation = iota | ||
Encryption | ||
Validation | ||
) | ||
|
||
// Error is the type of all errors returned by key encryption providers | ||
type Error struct { | ||
Operation Operation | ||
err error | ||
msg string | ||
} | ||
|
||
func (e *Error) Error() string { | ||
return e.msg | ||
} | ||
|
||
func (e *Error) Unwrap() error { | ||
return e.err | ||
} | ||
|
||
func NewError(operation Operation, msg string, err error) error { | ||
return &Error{ | ||
Operation: operation, | ||
msg: msg, | ||
err: err, | ||
} | ||
} | ||
|
||
func KeyPathNotAllowed(path string, operation Operation) error { | ||
return NewError(operation, fmt.Sprintf("Key path not allowed: %s", path), nil) | ||
} |
Oops, something went wrong.