Skip to content

Conversation

@som-snytt
Copy link
Contributor

Make ControlThrowable a class with suppression and stack trace disabled.

This change would affect anyone mixing the trait into a custom Error or checked exception.

@scala-jenkins scala-jenkins added this to the 2.13.0-RC1 milestone Nov 11, 2018
@som-snytt som-snytt added the WIP label Nov 11, 2018
@NthPortal
Copy link
Contributor

For a more migration-friendly attempt at solving this problem, see #7165

Also, this fixes scala/bug#11116

@som-snytt
Copy link
Contributor Author

@NthPortal thanks, obviously I didn't know you were already thinking about this.

@som-snytt
Copy link
Contributor Author

Obviously, I'm being very lazy about this (because I'm using my repo for a different PR):

non-fatal-tests.scala:19: error: class ControlThrowable is abstract; cannot be instantiated

@som-snytt
Copy link
Contributor Author

@NthPortal I tweaked the handling of ControlThrowable in Using and updated the tests, which I found challenging to pick up but I finally got the hang of it. In particular, the breaking change, that a test function used to throw CT (which is fatal) and now would throw a non-fatal, meant that catchThrowable would produce an unhelpful assert because Try in Using would no longer throw.

@som-snytt

This comment has been minimized.

Copy link
Contributor

@NthPortal NthPortal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't break known uses, I would prefer extending Throwable

@som-snytt
Copy link
Contributor Author

som-snytt commented Dec 6, 2018

Just to note: the purpose of the PR was to exploit the newer constructor, but that sacrifices flexibility of the mix-in. It might be desirable to have both a non-Exception and an Exceptional version.

MacroExpansionException for example. Is that a use case? or a red herring?

It's obvious from the Scaladoc that it was originally intended as a marker only, for all sorts of throwables, but maybe that intention was never fully realized.

The clean-up adjusts the constructor and the Scaladoc.

@NthPortal
Copy link
Contributor

I think this is ready for merge once it's squashed? cc @SethTisue

ControlThrowable never suppresses

ControlThrowable stack trace can be writable

Deprecate ControlThrowable with trace

Assert order and message

Test improvements

ControlThrowable is not exceptional

Since ControlThrowable is now more opinionated, just make it
a Throwable, following the adage that Exceptions are for
exceptional conditions.

Update the doc to use NonFatal when catching, as the previous
example contended with ControlThrowable mixed into arbitrary
exceptions.
@lrytz lrytz merged commit fa21650 into scala:2.13.x Dec 12, 2018
@som-snytt som-snytt deleted the topic/ctl-throw branch December 12, 2018 14:45
@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Jan 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes worth highlighting in next release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants