Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifErrorDo: should be onErrorDo: and deprecate with transform #6158

Conversation

astares
Copy link
Member

@astares astares commented Apr 8, 2020

  1. Rename #ifErrorDo: into #onErrorDo:
  2. use #onErrorDo: in deprecated methods like #ifError: and #ifErrorDo:
    and move these to Deprecated90 package
  3. have a transformation rule for the deprecations in #ifError: and #ifErrorDo:
  4. Add a test #testOnErrorDo

Fix #6157

1. Rename #ifErrorDo: into #onErrorDo:
2. use #onErrorDo: in deprecated methods like #ifError: and  #ifErrorDo:
     and move these to Deprecated90 package
3. have a transformation rule for the deprecations in  #ifError: and  #ifErrorDo:
4. Add a test #testOnErrorDo

Fix pharo-project#6157
@astares
Copy link
Member Author

astares commented Apr 8, 2020

@dionisiydk Can you please check again? Thanks in advance!

ifTrue: [ self deprecated: 'Use #onErrorDo: instead.' transformWith: '`@receiver ifError: `@arg' -> '`@receiver onErrorDo: `@arg' ]
ifFalse: [ self deprecated: 'Use #onErrorDo: instead.' ].

^ self onErrorDo: errorHandlerBlock
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to wrap it like:

self onErrorDo: [:err | errorHandlerBlock cull: err receiver cull: err description]

But I did not check in code what exact #cull:cull: it should be to be compatible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why wrap? We just dispatch further on. Do you have a problematic case?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is original method:

ifError: errorHandlerBlock
   ^ self on: Error do: [:ex |
		errorHandlerBlock cull: ex description cull: ex receiver]

The issue is about eliminating this strange error unboxing so that the handler block will accept a normal error instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

what I am trying to say is that deprecated method should continue work with this strange two parameters

Copy link
Member

Choose a reason for hiding this comment

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

Yes, the deprecated method should continue working as before :)

@guillep
Copy link
Member

guillep commented Apr 15, 2020

ping?

@guillep guillep added Status: Need more work The issue is nearly ready. Waiting some last bits. Type: Enhancement labels Apr 16, 2020
@guillep guillep mentioned this pull request Apr 16, 2020
@astares
Copy link
Member Author

astares commented Apr 22, 2020

@guillep pong!

Deprecated ifError: and ifErrorDo: should keep compatibility, otherwise they break the idea of a deprecation.
They are called with a block expecting description and receiver as arguments => honor that.
Removed the automatic rewriting as the rewriting rule for that may not be that obvious => let the user decide.
@guillep
Copy link
Member

guillep commented Apr 24, 2020

I've made the deprecated methods work as before to keep compatibility. Let's wait for the CI

Copy link
Member

@guillep guillep left a comment

Choose a reason for hiding this comment

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

The overall changes look ok. Let's wait for the CI.

@Ducasse Ducasse merged commit c896913 into pharo-project:Pharo9.0 Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Need more work The issue is nearly ready. Waiting some last bits. Type: Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ifErrorDo: should be onErrorDo: and deprecate with transform
4 participants