FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: add informative messages to error classes by java-james · Pull Request #144 · java-james/flutter_dotenv · GitHub

Repository navigation

fix: add informative messages to error classes - #144

Merged
java-james merged 2 commits into
masterfrom
jc/fix-error-message-clarity
Apr 21, 2026
Merged

java-james merged 2 commits into
masterfrom
jc/fix-error-message-clarity

Conversation

java-james commented Apr 21, 2026 •
edited
Loading

Copy link
Copy Markdown
Owner

Summary

  • NotInitializedError, FileNotFoundError, and EmptyEnvFileError now override toString() with actionable, context-rich messages instead of the unhelpful Instance of 'ClassName'
  • FileNotFoundError and EmptyEnvFileError now carry the filename when available (e.g. FileNotFoundError: Environment file ".env" not found. Ensure the file exists and is listed under assets in pubspec.yaml.)
  • loadFromString() without a filename correctly shows EmptyEnvFileError: The provided env string is empty.

Fixes or partially fixes #72, #127

Not a breaking change

  • Class names and hierarchy (extends Error) are unchanged — existing on FileNotFoundError catch clauses are unaffected
  • FileNotFoundError constructor uses an optional positional parameter ([this.filename]) — FileNotFoundError() still compiles
  • EmptyEnvFileError constructor uses an optional named parameter ({this.filename}) — EmptyEnvFileError() still compiles

Test plan

  • New test/errors_test.dart with 10 tests covering toString() output, field accessibility, integration with non-global DotEnv instances, and loadFromString() throw path
  • All 53 tests pass (flutter test)
  • Zero new analyzer warnings (flutter analyze)
  • Example app unchanged — does not reference error classes directly

java-james merged commit 2d15c7d into master Apr 21, 2026
1 check passed
This file contains hidden or 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
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

Successfully merging this pull request may close these issues.

FileNotFoundError

1 participant


Back | FazBrowse Home | New Git URL