Skip to content

Commit

Permalink
feat: Add throwExceptionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Aug 12, 2024
1 parent 27529f2 commit 62e10a1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/iris_method_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,32 @@ void main() {
await irisMethodChannel.dispose();
},
);

test(
'throwExceptionHandler throw Exception by default',
() async {
final currentThrowExceptionHandler = throwExceptionHandler;

expect(() => throwExceptionHandler(code: 1, message: 'message'),
throwsA(isA<Exception>()));

throwExceptionHandler = currentThrowExceptionHandler;
},
);

test(
'Can override throwExceptionHandler',
() async {
final currentThrowExceptionHandler = throwExceptionHandler;

throwExceptionHandler = ({required int code, String? message}) {
throw StateError('message');
};

expect(() => throwExceptionHandler(code: 1, message: 'message'),
throwsA(isA<StateError>()));

throwExceptionHandler = currentThrowExceptionHandler;
},
);
}

0 comments on commit 62e10a1

Please sign in to comment.