WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 660b7b0

Browse files
committed
+Improve error handling
1 parent 8cd1721 commit 660b7b0

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
[![pub](https://img.shields.io/pub/v/df_log.svg)](https://pub.dev/packages/df_log)
44
[![tag](https://img.shields.io/badge/Tag-v0.3.26-purple?logo=github)](https://github.com/dev-cetera/df_log/tree/v0.3.26)
5-
65
[![buymeacoffee](https://img.shields.io/badge/Buy%20Me%20A%20Coffee-FFDD00?logo=buy-me-a-coffee&logoColor=black)](https://www.buymeacoffee.com/dev_cetera)
76
[![sponsor](https://img.shields.io/badge/Sponsor-grey?logo=github-sponsors&logoColor=pink)](https://github.com/sponsors/dev-cetera)
8-
[![patreon](https://img.shields.io/badge/Patreon-grey?logo=patreon)](https://www.patreon.com/RobertMollentze)
9-
7+
[![patreon](https://img.shields.io/badge/Patreon-grey?logo=patreon)](https://www.patreon.com/t0mb3rr)
108
[![discord](https://img.shields.io/badge/Discord-5865F2?logo=discord&logoColor=white)](https://discord.gg/gEQ8y2nfyX)
119
[![instagram](https://img.shields.io/badge/Instagram-E4405F?logo=instagram&logoColor=white)](https://www.instagram.com/dev_cetera/)
12-
1310
[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/dev-cetera/df_log/main/LICENSE)
1411

1512
---
@@ -182,3 +179,4 @@ If you're enjoying this package and find it valuable, consider showing your appr
182179
## LICENSE
183180

184181
This project is released under the [MIT License](https://raw.githubusercontent.com/dev-cetera/df_log/main/LICENSE). See [LICENSE](https://raw.githubusercontent.com/dev-cetera/df_log/main/LICENSE) for more information.
182+

lib/src/log.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -548,14 +548,22 @@ final class Log {
548548
items.add(logItem);
549549
}
550550

551-
// Execute all callbacks.
551+
// Execute all callbacks and catch errors.
552+
final callbackErrors = <Object>[];
552553
for (final callback in callbacks) {
553-
callback(logItem);
554+
try {
555+
callback(logItem);
556+
} catch (e) {
557+
callbackErrors.add(e);
558+
}
554559
}
555560

556561
// Only print if combinedTags is empty or any of combinedTags are in activeTags.
557-
if (combinedTags.isNotEmpty &&
558-
!activeTags.any((e) => combinedTags.contains(e))) {
562+
if (combinedTags.isNotEmpty && !activeTags.any((e) => combinedTags.contains(e))) {
563+
// Throw any errors before returning.
564+
for (final e in callbackErrors) {
565+
throw e;
566+
}
559567
return;
560568
}
561569

@@ -567,6 +575,10 @@ final class Log {
567575
)
568576
: logItem.toConsoleString();
569577
_printFunction(output);
578+
// Throw any errors before returning.
579+
for (final e in callbackErrors) {
580+
throw e;
581+
}
570582
}
571583

572584
//

pubspec.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ homepage: https://dev-cetera.com/
1616
repository: https://github.com/robmllze/df_log
1717
funding:
1818
- https://www.buymeacoffee.com/dev_cetera
19-
- https://www.patreon.com/RobertMollentze
20-
- https://github.com/sponsors/robmllze
19+
- https://www.patreon.com/c/t0mb3rr
20+
- https://github.com/sponsors/t0mb3rr
21+
2122
description: A package that provides logging utilities for better debugging.
22-
version: 0.3.26
23+
version: 0.3.27
2324
topics:
2425
- console
2526
- debugging

0 commit comments

Comments
 (0)