Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support returning multiple errors when parsing env #3

Merged
merged 5 commits into from
Feb 9, 2023

Conversation

johncowie
Copy link
Contributor

@johncowie johncowie commented Jul 25, 2020

When I'm starting up my app with environment variables I'd prefer to know all the variable parsing errors at once (as opposed to fixing one -> restarting the app -> finding out the next error and fixing that one etc..).

This PR updates the EnvError type to support accumulating multiple errors.

@@ -50,20 +50,28 @@ type VariableFlipped ty name = Variable name ty
infixr 5 type VariableFlipped as <:

-- | An error that can occur while reading an environment variable
data EnvError = EnvLookupError String | EnvParseError String
data EnvError = EnvLookupError String | EnvParseError String | EnvErrors (Array EnvError)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very useful feature!

but why not just change the parser return type to from EnvError to Array EnvError

without changing EnvError

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, @srghma. I'm going to merge this change as-is but will follow up with your recommendation.

@nsaunders nsaunders merged commit 24438d4 into nsaunders:master Feb 9, 2023
nsaunders added a commit that referenced this pull request Feb 9, 2023
nsaunders added a commit that referenced this pull request Feb 9, 2023
nsaunders added a commit that referenced this pull request Feb 9, 2023
@nsaunders nsaunders added the enhancement New feature or request label Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants