error_guard 1.0.3
error_guard: ^1.0.3 copied to clipboard
A powerful, declarative error-handling library for Dart and Flutter with type promotion and precise runtime tracking.
Changelog #
1.0.3 - 2026-03-24 #
Added #
- Generic Exception & Error System: Introduced
GenericCheckedExceptionandGenericUncheckedErrorto provide a standardized way of handling Dart core exceptions and errors. - Structured Data Tracking: Added the ability to capture the raw
valueand itsruntimeTypewithin exceptions to enable rapid identification of type mismatches during debugging. - Dart Core Mapping: Added
DartExceptionMessageandDartErrorMessageenums to provide consistent error prefixes and default messages for common Dart-related failures. - Specialized Internal Concrete Classes:
_FormatException: Captures specificoffsetdata for parsing errors._OutOfError: Capturesstartandendrange information for index and range-related errors._IntegerDivisionByZeroException: Specifically handles non-finite division results.
- Factory Methods: Added
.dartCore()factory constructors to bothGenericCheckedExceptionandGenericUncheckedErrorfor a unified entry point when wrapping standard Dart failures.
Changed #
- Enhanced Diagnostics: Improved
createMessagelogic to automatically include type information and structured body parts (English/Locale) in the error output. - Strict Encapsulation: Concrete exception subclasses are now private (
_), forcing the use of the centralized factory system and ensuring API stability. - Naming Consistency: Updated internal enum members (e.g.,
noSuchMethodNotFound,outOfRange) to prevent naming collisions with existing Dart top-level functions or properties.
Fixed #
- Consistency in Error Output: Fixed inconsistent string representations by overriding
toString()to ensure allUncheckedErrorinstances follow theprefix + Errorformat. - StackTrace Handling: Refined the
UncheckedErrorstructure to ensureStackTraceis properly preserved and exposed for logical system errors.
1.0.1 - 2026-03-23 #
Added #
- Comprehensive Examples:
- Added
example/main.dartcovering all core features including Type Promotion and Error/Exception separation. - Added
example/fpdart_example.dartdemonstrating seamless integration with functional programming patterns usingEitherandTaskEither.
- Added
- Project Metadata: Added
homepage,repository,issue_tracker, andtopicstopubspec.yamlfor better discoverability on pub.flutter-io.cn.
Changed #
- Documentation Refinement: Updated all doc comments to use backticks (
`value`) instead of brackets ([value]) where symbol resolution was not possible, resolving alldartdocwarnings. - Improved Type Safety: Refined
messagerecord types in extension methods to ensure consistent behavior across the API.
Fixed #
- Unresolved Doc References: Fixed 7
dartdocwarnings related to unresolved references inBaseExceptionXandBaseExceptionOrNullX. - TaskEither Type Inference: Corrected a type mismatch in the fpdart example to ensure proper
CheckedException<T>propagation.
All notable changes to this project will be documented in this file.
1.0.0 - 2026-03-23 #
Added #
- Core Architecture: Introduced
BaseException,CheckedException, andUncheckedErrorfor structured error handling. - Precision Type Tracking: Added an intelligent tracking engine that compares expected types
($T)with actualruntimeTypeto provide detailed debugging context. - Extension Methods:
BaseExceptionX: Seamless conversion of any object into an exception or error.BaseExceptionOrNullX: Added support for convertingnullvalues into structured exceptions with accurate type tracing.ThrowableX: Declarative condition checks (throwCheckedIf) for cleaner business logic.NullableCheckedX&NullableUncheckedX: Integrated null-safety validation with automatic Type Promotion.
- Localization System: Implemented structured multi-language support with mandatory
englishand optionallocalefields. - Dynamic Formatting: Optimized log generation using
List.join()to ensure clean output without unnecessary empty lines. - Comprehensive Documentation: Provided English and Korean READMEs with IDE-safe, runnable code examples.
- Test Suite: Developed full unit tests covering type promotion, message building, and error classification.
Changed #
- Refined
createMessagelogic to gracefully handle optionallocalestrings. - Updated extension methods to preserve original
thisvalues, ensuring accurate type analysis in lower layers. - Encapsulated internal implementations (
Generic...) by restricting public exports viaindex.dart.
Fixed #
- Resolved an issue where missing
localestrings caused unwanted blank lines in error logs. - Fixed syntax errors in documentation examples by wrapping snippets in function blocks and ensuring explicit
nullfor record fields.