-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add error handling to env parsers (#111)
* refactor: Add error handling to env parsers * refactor: Get rid of internal default value parsers * style: Fix linter warnings
- Loading branch information
1 parent
1887d16
commit 011a926
Showing
9 changed files
with
1,689 additions
and
1,269 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
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 |
---|---|---|
@@ -1,10 +1,25 @@ | ||
package internal | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ( | ||
// ErrNotSet is an error that is returned when the environment variable is not set. | ||
ErrNotSet = errors.New("not set") | ||
// ErrInvalidValue is an error that is returned when the environment variable is not valid. | ||
ErrInvalidValue = errors.New("invalid value") | ||
) | ||
|
||
func newErrInvalidValue(msg string) error { | ||
return newWrapErr(msg, ErrInvalidValue) | ||
} | ||
|
||
func newErrNotSet(msg string) error { | ||
return newWrapErr(msg, ErrNotSet) | ||
} | ||
|
||
func newWrapErr(msg string, wrapErr error) error { | ||
return fmt.Errorf("%s: %w", msg, wrapErr) | ||
} |
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
Oops, something went wrong.