Skip to content

flutter tool is too aggressive about catching exceptions #8742

Closed

Description

@Hixie

There are a number of places in the flutter tool where we just catch any exception, print it, then move on, or return failure.

This is masking real errors, and results in confusing error messages. For example, it catches NoSuchMethodErrors and prints them to the user, instead of crashing and generating a crash log.

try .. catch blocks should only catch expected exceptions that can be handled, or that can be usefully reported before aborting cleanly.

We should remove all cases of blanket-catching exceptions, and all cases of catching exceptions and printing them but otherwise continuing unaffected.

You can easily find affected files by search for the regexp pattern } catch \([a-z_]+\) {.

cc @johnmccutchan

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    on Mar 13, 2017
  2. modified the milestones: , 2: Make Early Adopters happy on Apr 4, 2017
  3. zoechi commented on Nov 28, 2018

    @zoechi
    Contributor

    Enabling the linter rule avoid_catches_without_on_clauses would enforce this
    https://github.com/flutter/flutter/blob/master/analysis_options.yaml#L52

  4. Levi-Lesches commented on Oct 13, 2019

    @Levi-Lesches
  5. vkammerer commented on Oct 14, 2019

    @vkammerer
  6. Hixie commented on Oct 14, 2019

    @Hixie
    Author
  7. radiKal07 commented on Mar 3, 2020

    @radiKal07

    What is flutter tool, or what is the difference between flutter and flutter tool?
    Is this issue only a dev thing, or also happening in release?

  8. zanderso commented on Mar 6, 2020

    @zanderso
    Member

    In #52021, the tool has enabled the avoid_catches_without_on_clauses lint.

  9. christopherfujino commented on Mar 9, 2020

    @christopherfujino
    Contributor

    What is flutter tool, or what is the difference between flutter and flutter tool?
    Is this issue only a dev thing, or also happening in release?

    @Tudor07 this only affects devs. The "flutter tool" is the command line tool used in flutter development: https://github.com/flutter/flutter/tree/master/packages/flutter_tools

  10. lock commented on Apr 5, 2020

    @lock

    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.

  11. locked and limited conversation to collaborators on Apr 5, 2020
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

    toolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions