Skip to content

Commit

Permalink
test: also call toStringWithCause
Browse files Browse the repository at this point in the history
  • Loading branch information
hpoul committed Feb 18, 2024
1 parent a21354c commit ece5b0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/exception_chain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ extension CausedByException<E extends Exception> on E {
final error = cause.error;
final causeToString =
error is Exception ? error.toStringWithCause() : error.toString();
return '${toString()} cause: {$causeToString}';
return '${toString()} (cause: $causeToString)';
}
}
2 changes: 2 additions & 0 deletions test/exception_chain_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void main() {
} on Exception catch (e, stackTrace) {
expect(e.getCausedByException(), isNotNull);
expect(e.getCausedByException()?.error, isFormatException);
expect(e.toStringWithCause(), contains('FormatException'));
_logger.finer('toStringWithCause: ${e.toStringWithCause()}');
_logger.finer('catched exception.', e, stackTrace);
}
});
Expand Down

0 comments on commit ece5b0c

Please sign in to comment.