Skip to content

Proper error when it can't find or parse the dotenv file #62

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

Open
maxp-edcast opened this issue Nov 16, 2018 · 1 comment
Open

Proper error when it can't find or parse the dotenv file #62

maxp-edcast opened this issue Nov 16, 2018 · 1 comment

Comments

@maxp-edcast
Copy link

maxp-edcast commented Nov 16, 2018

In the source code we have

// It's important to note that it WILL NOT OVERRIDE an env variable that already exists - consider the .env file to set dev vars or sensible defaults
func Load(filenames ...string) (err error) {
	filenames = filenamesOrDefault(filenames)

	for _, filename := range filenames {
		err = loadFile(filename, false)
		if err != nil {
			return // return early on a spazout
		}
	}
	return
}

the return // return early on a spazout behavior is questionable, in my opinion. I think it should show a normal error somehow, since it makes things easier to debug.

In my case it turned out to be an error with env file being parsed, since I had an accidental newline in one of the variables. However I couldn't figure this out without going into the dotenv source code and adding some logger statements.

@maxp-edcast maxp-edcast changed the title Meaningful error when it can't find the dotenv file error when it can't find the dotenv file Nov 16, 2018
@maxp-edcast maxp-edcast changed the title error when it can't find the dotenv file should have error when it can't find the dotenv file? Nov 16, 2018
@maxp-edcast maxp-edcast changed the title should have error when it can't find the dotenv file? Proper error when it can't find or parse the dotenv file Nov 16, 2018
@joho
Copy link
Owner

joho commented Nov 20, 2018

Were you checking the returned err from the function? I wrote that a long time ago and it's in the now very non-idiomatic named/naked return so the error should be available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants