Add support for throwing if failed#165
Conversation
|
I think a better alternative would be to return the error instead of false so consumers can handle the error as they please (throw, report, ignore, etc.) |
|
Yeah, it's better than returning |
|
Please correct me if I'm wrong. The motivation to add an option to throw the error is to control how the error is handled. Instead of adding options, perhaps it's better to remove one and change what's returned from import { config } from 'dotenv'
import variableExpansion from 'dotenv-expand'
env = config()
if (env.error) {
// handle error as you like
throw env.error
}
variableExpansion(env.parsed)This is a low-impact path forward for anyone upgrading major versions. It allows people to continue ignoring errors that are most likely due to a missing file in environments like CI.
|
182505f to
0879b15
Compare
0879b15 to
25ffb08
Compare
maxbeatty
left a comment
There was a problem hiding this comment.
looks good. will wait for more feedback and review before merging
|
This looks good my only concern is with the the return object change and external plugins that do not have I do not think there is many of these plugins out there, but I do think it would be a good idea, if this is merged, that we make either PRs or issues to update to support both versions. So that way on release we are not breaking those plugins functionality. |
|
other modules should specify peer dependencies to indicate which versions of dotenv they are compatible with |
I agree. 👍 for this PR |
If
verbose: 'throw'is passed in options, anErroris thrown instead ofconsole.erroring to the stdout