Skip to content

Commit 9924678

Browse files
committed
Release v9.1.1: Rename filter and add GlobalErrorFilter
Improvements: - Renamed FirstLocalThenGlobalErrorFilter to GlobalIfNoLocalErrorFilter for better clarity - Name now clearly indicates "global if no local handler" behavior New Features: - Added GlobalErrorFilter that routes errors ONLY to global handler - Returns ErrorReaction.globalHandler (not firstLocalThenGlobal) - Useful when you want all errors to go global regardless of local listeners Fixes: - Removed incorrectly deprecated GlobalErrorFilter from v9.1.0 - Replaced with correct implementation Tests: - Added test for GlobalErrorFilter behavior - All 38 tests passing
1 parent d58de85 commit 9924678

File tree

8 files changed

+57
-19
lines changed

8 files changed

+57
-19
lines changed

CHANGELOG.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
[9.1.1] - 2025-11-21
2+
3+
### Improvements
4+
5+
- **Renamed GlobalIfNoLocalErrorFilter**: Renamed `FirstLocalThenGlobalErrorFilter` to `GlobalIfNoLocalErrorFilter` for better clarity. The name now clearly indicates "global if no local handler".
6+
7+
### New Features
8+
9+
- **Added GlobalErrorFilter**: New filter that routes errors ONLY to the global handler, regardless of local listeners. Returns `ErrorReaction.globalHandler`.
10+
11+
### Fixes
12+
13+
- **Removed incorrectly named GlobalErrorFilter**: The previous `GlobalErrorFilter` that was deprecated in v9.1.0 has been removed and replaced with the correct implementation.
14+
115
[9.1.0] - 2025-11-21
216

317
### New Features
@@ -45,9 +59,9 @@ class MyApp extends WatchingWidget {
4559
- **Improved ErrorFilter class naming consistency**: Renamed `ErrorHandler*` classes to simpler `*ErrorFilter` pattern to better align with existing filters. Old names remain functional with deprecation warnings until v10.0.0.
4660

4761
**Class name changes:**
48-
- `ErrorHandlerGlobalIfNoLocal``GlobalErrorFilter` (deprecated)
62+
- `ErrorHandlerGlobalIfNoLocal``GlobalIfNoLocalErrorFilter` (deprecated)
4963
- `ErrorHandlerLocal``LocalErrorFilter` (deprecated)
50-
- `ErrorHandlerLocalAndGlobal``LocalAndGlobalErrorFilter` (deprecated)
64+
- `ErrorHandlerLocalAndGlobal``LocalAndGlobalIfNoLocalErrorFilter` (deprecated)
5165

5266
**Why this change:**
5367
- Better naming consistency: matches `TableErrorFilter` and `PredicatesErrorFilter` pattern
@@ -62,7 +76,7 @@ Command.errorFilterDefault = const ErrorHandlerGlobalIfNoLocal();
6276
errorFilter: const ErrorHandlerLocal()
6377
6478
// New
65-
Command.errorFilterDefault = const GlobalErrorFilter();
79+
Command.errorFilterDefault = const GlobalIfNoLocalErrorFilter();
6680
errorFilter: const LocalErrorFilter()
6781
```
6882

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,16 @@ Every Command exposes multiple `ValueListenable` interfaces for different aspect
133133
- `throwIfNoLocalHandler`: Throw if no local listeners
134134

135135
**Built-in ErrorFilter implementations**:
136-
- `ErrorHandlerGlobalIfNoLocal`: Default behavior
137-
- `ErrorHandlerLocal`: Local only
138-
- `ErrorHandlerLocalAndGlobal`: Both handlers
136+
- `GlobalIfNoLocalErrorFilter`: Default behavior
137+
- `LocalErrorFilter`: Local only
138+
- `LocalAndGlobalIfNoLocalErrorFilter`: Both handlers
139139
- `TableErrorFilter`: Map error types to reactions
140140
- `PredicatesErrorFilter`: Chain of predicate functions
141141
- `ErrorFilterExcemption<T>`: Special handling for specific type
142142

143143
**Global configuration**:
144144
```dart
145-
Command.errorFilterDefault = const ErrorHandlerGlobalIfNoLocal();
145+
Command.errorFilterDefault = const GlobalIfNoLocalErrorFilter();
146146
Command.globalExceptionHandler = (error, stackTrace) { /* log */ };
147147
Command.assertionsAlwaysThrow = true; // AssertionErrors bypass filters
148148
Command.reportAllExceptions = false; // Override filters, report everything

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Declarative error routing with filters:
159159
- **[Global Handler](https://flutter-it.dev/documentation/command_it/error_handling#global-handler)** — App-wide error handling
160160
- **[Global Errors Stream](https://flutter-it.dev/documentation/command_it/global_configuration#globalerrors)** — Reactive monitoring of all globally-routed errors
161161
- **[Error Filters](https://flutter-it.dev/documentation/command_it/error_filters)** — Route errors by type or predicate
162-
- **[Built-in Filters](https://flutter-it.dev/documentation/command_it/error_filters#built-in-filters)**GlobalErrorFilter, PredicatesErrorFilter, etc.
162+
- **[Built-in Filters](https://flutter-it.dev/documentation/command_it/error_filters#built-in-filters)**GlobalIfNoLocalErrorFilter, PredicatesErrorFilter, etc.
163163

164164
### Advanced Features
165165

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ packages:
3939
path: ".."
4040
relative: true
4141
source: path
42-
version: "9.0.2"
42+
version: "9.1.1"
4343
flutter:
4444
dependency: "direct main"
4545
description: flutter

lib/command_it.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ abstract class Command<TParam, TResult> extends CustomValueNotifier<TResult> {
554554

555555
/// if no individual ErrorFilter is set when creating a Command
556556
/// this filter is used in case of an error
557-
static ErrorFilter errorFilterDefault = const GlobalErrorFilter();
557+
static ErrorFilter errorFilterDefault = const GlobalIfNoLocalErrorFilter();
558558

559559
/// `AssertionErrors` are almost never wanted in production, so by default
560560
/// they will dirextly be rethrown, so that they are found early in development

lib/error_filters.dart

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class ErrorFilerConstant implements ErrorFilter {
6464

6565
/// Error filter that routes errors to global handler if no local handler is present.
6666
/// This is the default error filter for all commands.
67-
class GlobalErrorFilter implements ErrorFilter {
68-
const GlobalErrorFilter();
67+
class GlobalIfNoLocalErrorFilter implements ErrorFilter {
68+
const GlobalIfNoLocalErrorFilter();
6969
@override
7070
ErrorReaction filter(Object error, StackTrace stackTrace) {
7171
return ErrorReaction.firstLocalThenGlobalHandler;
@@ -91,10 +91,10 @@ class LocalAndGlobalErrorFilter implements ErrorFilter {
9191
}
9292

9393
/// @nodoc
94-
/// Deprecated: Use [GlobalErrorFilter] instead.
94+
/// Deprecated: Use [GlobalIfNoLocalErrorFilter] instead.
9595
/// Will be removed in v10.0.0
9696
@Deprecated(
97-
'Use GlobalErrorFilter instead. '
97+
'Use GlobalIfNoLocalErrorFilter instead. '
9898
'Will be removed in v10.0.0',
9999
)
100100
class ErrorHandlerGlobalIfNoLocal implements ErrorFilter {
@@ -105,6 +105,17 @@ class ErrorHandlerGlobalIfNoLocal implements ErrorFilter {
105105
}
106106
}
107107

108+
/// Error filter that routes errors only to the global handler.
109+
/// Use this when you want all errors to go to the global handler,
110+
/// regardless of whether there are local listeners.
111+
class GlobalErrorFilter implements ErrorFilter {
112+
const GlobalErrorFilter();
113+
@override
114+
ErrorReaction filter(Object error, StackTrace stackTrace) {
115+
return ErrorReaction.globalHandler;
116+
}
117+
}
118+
108119
/// @nodoc
109120
/// Deprecated: Use [LocalErrorFilter] instead.
110121
/// Will be removed in v10.0.0

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: command_it
22
description: command_it is a way to manage your state based on `ValueListenable` and the `Command` design pattern. It is a rebranding of flutter_command.
3-
version: 9.1.0
3+
version: 9.1.1
44
homepage: https://github.com/flutter-it/command_it
55

66
screenshots:

test/error_test.dart

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ void main() {
140140
});
141141

142142
// Tests for new ErrorFilter classes
143-
test('GlobalErrorFilter', () {
144-
const filter = GlobalErrorFilter();
143+
test('GlobalIfNoLocalErrorFilter', () {
144+
const filter = GlobalIfNoLocalErrorFilter();
145145

146146
expect(
147147
filter.filter(Error(), StackTrace.current),
@@ -153,6 +153,19 @@ void main() {
153153
);
154154
});
155155

156+
test('GlobalErrorFilter', () {
157+
const filter = GlobalErrorFilter();
158+
159+
expect(
160+
filter.filter(Error(), StackTrace.current),
161+
ErrorReaction.globalHandler,
162+
);
163+
expect(
164+
filter.filter(Exception(), StackTrace.current),
165+
ErrorReaction.globalHandler,
166+
);
167+
});
168+
156169
test('LocalErrorFilter', () {
157170
const filter = LocalErrorFilter();
158171

@@ -708,7 +721,7 @@ void main() {
708721
final cmd = Command.createAsyncNoParam(
709722
() async => throw Exception('Test error'),
710723
initialValue: null,
711-
errorFilter: const GlobalErrorFilter(),
724+
errorFilter: const GlobalIfNoLocalErrorFilter(),
712725
);
713726

714727
await cmd.runAsync().catchError((_) {});
@@ -774,7 +787,7 @@ void main() {
774787
final globalCmd = Command.createAsyncNoParam(
775788
() async => throw Exception('Global error'),
776789
initialValue: null,
777-
errorFilter: const GlobalErrorFilter(),
790+
errorFilter: const GlobalIfNoLocalErrorFilter(),
778791
);
779792

780793
await globalCmd.runAsync().catchError((_) {});

0 commit comments

Comments
 (0)