-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#219Labels
c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Description
@gaaclarke
I'm using pigeon 0.10.0.
When calling a platform method that generates an NPE (on the platform side) the pigeon code is generating an assert:
2020-10-08 11:12:46.626 6638-6672/com.bsutton.sounds.sounds_example E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: 'package:flutter/src/services/message_codec.dart': Failed assertion: line 111 pos 15: 'code != null': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 new PlatformException (package:flutter/src/services/message_codec.dart:111:15)
#3 SoundsToPlatformApi.startPlayer (package:sounds_platform_interface/sounds_platform_interface.dart:868:13)The pigeon code generates:
}
private static HashMap wrapError(Exception exception) {
HashMap<String, Object> errorMap = new HashMap<>();
errorMap.put("message", exception.toString());
errorMap.put("code", null);
errorMap.put("details", null);
return errorMap;
}As you can see the generated code sets put("code", null) which the core messages_code class does not accept.
My suggestion would be to set 'code' to be the simple name of the exception.
gaaclarke
Metadata
Metadata
Assignees
Labels
c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.