Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the try for an except or finally

I'm dealing with some code that has fantastically long methods (10k lines!) and some odd use of try-finally and try-except blocks. Some of the latter are long by themselves, and don't always have the try at the start of the method.

Obviously I'm trying to refactor the code, but in the meantime just being able to fix a couple of common pathologies would be much easier if I could jump to the start of a block and see what is happening there. When it's 20+ pages away finding it even with the CNPack rainbows ("code structure highlight") is just tedious.

I'm using D2010 and have GExperts (with DelForExp), CNPack and DDevExtensions installed, but I can't find anything that lets me jump from the try to the finally or back. Am I missing something? Is there another add-in that I can use that will get me this?

like image 397
Móż Avatar asked Jun 25 '13 02:06

Móż


People also ask

When to use try-except finally?

The try block lets you test a block of code for errors. The except block lets you handle the error. The else block lets you execute code when there is no error. The finally block lets you execute code, regardless of the result of the try- and except blocks.

What is try catch and except And finally keyword?

Exception handling with try, except, else, and finally Try: This block will test the excepted error to occur. Except: Here you can handle the error. Else: If there is no exception then this block will be executed. Finally: Finally block always gets executed either exception is generated or not.

How do you handle exceptions with try finally?

When an exception is thrown in the try block, the execution immediately passes to the finally block. After all the statements in the finally block are executed, the exception is raised again and is handled in the except statements if present in the next higher layer of the try-except statement.

How do you use try-except statement?

The try statement works as follows. First, the try clause (the statement(s) between the try and except keywords) is executed. If no exception occurs, the except clause is skipped and execution of the try statement is finished. If an exception occurs during execution of the try clause, the rest of the clause is skipped.


1 Answers

GExperts have it in Editor Experts: "Move to Matching Delimiter", with the keyboard shortcut Ctrl+Alt+Right by default. If you invoke it repeatedly it cycles from try to the matching finally or except, to end, then back to try, and so on.

like image 107
Ondrej Kelle Avatar answered Sep 28 '22 07:09

Ondrej Kelle