Extract Method inside try/catch

I came across a problem today in some code I'm cleaning up and can't convince myself ReSharper's behavior is correct.

I am trying to do an Extract Method on some code that lies inside a try/catch block. The code I'm looking to extract throws exceptions. When I try to extract it, ReSharper says "Extracted block has more than one exit point."

Here's a very simple example that mimics the problem:


If I highlight lines 3-5 and try ExtractMethod I get the 'more than one exit point' message.

Is ReSharper correct and I'm overlooking something?

-paul

2 comments
Comment actions Permalink

Hello Paul,

As far as I remember, it was reported and fixed.
Well, here is request: http://www.intellij.net/tracker/resharper/viewSCR?publicId=4063
It is broken in 161 now. JetBrains, please reopen request.

PM> I am trying to do an Extract Method on some code that lies inside a
PM> try/catch block. The code I'm looking to extract throws exceptions.
PM> When I try to extract it, ReSharper says "Extracted block has more
PM> than one exit point."
PM>
PM> Is ReSharper correct and I'm overlooking something?
PM>
PM> -paul
PM>
Sincerely,
Ilya Ryzhenkov


0
Comment actions Permalink

You are right, I reopened the SCR. It's not safe to fix it now and we anyway
are going to completely rewrite this part of the code for 2.0.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Paul,

As far as I remember, it was reported and fixed.
Well, here is request:
http://www.intellij.net/tracker/resharper/viewSCR?publicId=4063
It is broken in 161 now. JetBrains, please reopen request.

PM>> I am trying to do an Extract Method on some code that lies inside a
PM>> try/catch block. The code I'm looking to extract throws
PM>> exceptions. When I try to extract it, ReSharper says "Extracted
PM>> block has more than one exit point."
PM>>
PM>> Is ReSharper correct and I'm overlooking something?
PM>>
PM>> -paul
PM>>

Sincerely,
Ilya Ryzhenkov




0

Please sign in to leave a comment.