Skip to content

[pigeon] asserts when java platform throws NPE. #67586

Closed
flutter/packages
#219

Description

@bsutton

@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.

Activity

  1. gaaclarke commented on Oct 13, 2020

    @gaaclarke
    Member

    Thanks, landed it. I'll get this published in the next version. I was hoping to get a unit test for this but I don't want to hold it back any longer. This will be in 0.1.12.

  2. bsutton commented on Oct 14, 2020

    @bsutton
    Author

    thanks.

  3. github-actions commented on Aug 11, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  4. locked as resolved and limited conversation to collaborators on Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions