[ 
https://issues.apache.org/jira/browse/THRIFT-4646?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dave Walker updated THRIFT-4646:
--------------------------------
    Description: 
Thrift implemented dart output ~3 years ago and in doing so outputs exceptions 
in classes that extend Error[1].  At the time this commit[2] was done this was 
acceptable. However, a year or so after this commit Effective Dart introduced a 
rule that you "DON'T" catch Errors or anything that implements them[3].  
However, Dart SDK had for the Error type ~5 years ago that they should not be 
used for expect or catch[4].

As such this ticket requests that the generator for dart code should have 
exception types implement Exception rather than extending Error.  Although 
Error and Exception are used pretty interchangeably in terms of throwing, they 
do differ for the expect/catch and as such would warrant being included in a 
major version change.

[1] - 
[https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_dart_generator.cc#L781]

[2] - 
[https://github.com/apache/thrift/commit/932c4700c6e3aee20b74d5e2f562326029e6b9c8]

[3] - 
[https://www.dartlang.org/guides/language/effective-dart/usage#dont-explicitly-catch-error-or-types-that-implement-it]

[4] - 
[https://github.com/dart-lang/sdk/commit/460e157416212a0ce90dbfbc6e2e2f68c4e421e8]

  was:
Thrift implemented dart output ~3 years ago and in doing so outputs exceptions 
in classes that extend Error[1].  At the time this commit[2] was done this was 
acceptable. However, a year or so after this commit Effective Dart introduced a 
rule that you "DON'T" catch Errors or anything that implements them[3].  
However, Dart SDK had for the Error type ~5 years ago that they should not be 
used for expect or catch[4].

As such this ticket requests that the generator for dart code should have 
exception types extend Exception rather than extending Error.  Although Error 
and Exception are used pretty interchangeably in terms of throwing, they do 
differ for the expect/catch and as such would warrant being included in a major 
version change.

[1] - 
[https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_dart_generator.cc#L781]

[2] - 
[https://github.com/apache/thrift/commit/932c4700c6e3aee20b74d5e2f562326029e6b9c8]

[3] - 
[https://www.dartlang.org/guides/language/effective-dart/usage#dont-explicitly-catch-error-or-types-that-implement-it]

[4] - 
[https://github.com/dart-lang/sdk/commit/460e157416212a0ce90dbfbc6e2e2f68c4e421e8]


> Effective Dart and Exceptions
> -----------------------------
>
>                 Key: THRIFT-4646
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4646
>             Project: Thrift
>          Issue Type: Bug
>          Components: Dart - Compiler
>            Reporter: Dave Walker
>            Priority: Trivial
>
> Thrift implemented dart output ~3 years ago and in doing so outputs 
> exceptions in classes that extend Error[1].  At the time this commit[2] was 
> done this was acceptable. However, a year or so after this commit Effective 
> Dart introduced a rule that you "DON'T" catch Errors or anything that 
> implements them[3].  However, Dart SDK had for the Error type ~5 years ago 
> that they should not be used for expect or catch[4].
> As such this ticket requests that the generator for dart code should have 
> exception types implement Exception rather than extending Error.  Although 
> Error and Exception are used pretty interchangeably in terms of throwing, 
> they do differ for the expect/catch and as such would warrant being included 
> in a major version change.
> [1] - 
> [https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_dart_generator.cc#L781]
> [2] - 
> [https://github.com/apache/thrift/commit/932c4700c6e3aee20b74d5e2f562326029e6b9c8]
> [3] - 
> [https://www.dartlang.org/guides/language/effective-dart/usage#dont-explicitly-catch-error-or-types-that-implement-it]
> [4] - 
> [https://github.com/dart-lang/sdk/commit/460e157416212a0ce90dbfbc6e2e2f68c4e421e8]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to