Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Extend Rust to Dart error propagation (#213)
Browse files Browse the repository at this point in the history
- throw MediaStateTransitionException from RoomHandle enable / disable / mute / unmute local / remote audio / video methods
- throw MediaSettingsUpdateException from RoomHandle.set_local_media_settings()
- throw InternalException in cases of programmatic errors or unexpected platform failures
  • Loading branch information
alexlapa authored Jul 16, 2021
1 parent 85cb7c4 commit e8b58ea
Show file tree
Hide file tree
Showing 25 changed files with 858 additions and 356 deletions.
107 changes: 75 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions jason/flutter/example/integration_test/jason.dart
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,18 @@ void main() {
isFormatException,
predicate(
(e) => e.message.contains('relative URL without a base'))));

var localMediaErr = Completer<Object>();
room.onFailedLocalMedia((err) {
localMediaErr.complete(err);
});
var err = await localMediaErr.future;
expect(
err,
predicate((e) =>
e is MediaStateTransitionException &&
e.message == 'SimpleTracksRequest should have at least one track' &&
e.nativeStackTrace.contains('at jason/src')));
});

testWidgets('ReconnectHandle', (WidgetTester tester) async {
Expand Down Expand Up @@ -406,9 +418,9 @@ void main() {
() => returnsRpcClientException('Dart err cause1').unwrap(),
throwsA(predicate((e) =>
e is RpcClientException &&
e.kind == RpcClientExceptionKind.InternalError &&
e.kind == RpcClientExceptionKind.ConnectionLost &&
e.cause == 'Dart err cause1' &&
e.message == 'RpcClientException::InternalError' &&
e.message == 'RpcClientException::ConnectionLost' &&
e.nativeStackTrace.contains('at jason/src'))));

var exception5;
Expand Down Expand Up @@ -486,4 +498,24 @@ void main() {
str.free();
num.free();
});

testWidgets('Complex arguments validation', (WidgetTester tester) async {
final _muteVideo = dl.lookupFunction<Handle Function(Pointer, ForeignValue),
Object Function(Pointer, ForeignValue)>('RoomHandle__mute_video');

var jason = Jason();
var room = jason.initRoom();

var err;
var arg = ForeignValue.fromInt(123);
try {
await (_muteVideo(room.ptr.getInnerPtr(), arg.ref) as Future);
} catch (e) {
err = e as ArgumentError;
} finally {
arg.free();
}
expect(err.invalidValue, equals(123));
expect(err.name, 'kind');
});
}
Loading

0 comments on commit e8b58ea

Please sign in to comment.