Skip to content

Commit 3458ed5

Browse files
committed
Redirect stack trace
1 parent 132cb0d commit 3458ed5

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/sane/lib/src/isolate_messages/exception.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import 'package:sane/src/exceptions.dart';
22
import 'package:sane/src/isolate_messages/interface.dart';
33

44
class ExceptionResponse implements IsolateResponse {
5-
ExceptionResponse({required this.exception});
5+
ExceptionResponse({
6+
required this.exception,
7+
required this.stackTrace,
8+
});
69

710
final SaneException exception;
11+
final StackTrace stackTrace;
812
}

packages/sane/lib/src/sane_isolate.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ class SaneIsolate implements Sane {
5959
replyPort.close();
6060

6161
if (response is ExceptionResponse) {
62-
throw response.exception;
62+
Error.throwWithStackTrace(
63+
response.exception,
64+
response.stackTrace,
65+
);
6366
}
6467

6568
return response;
@@ -308,8 +311,11 @@ void _isolateEntryPoint(_IsolateEntryPointArgs args) {
308311
late IsolateResponse response;
309312
try {
310313
response = await envellope.message.handle(sane);
311-
} on SaneException catch (e) {
312-
response = ExceptionResponse(exception: e);
314+
} on SaneException catch (exception, stackTrace) {
315+
response = ExceptionResponse(
316+
exception: exception,
317+
stackTrace: stackTrace,
318+
);
313319
}
314320

315321
envellope.replyPort.send(response);

0 commit comments

Comments
 (0)