Questions tagged as 'try-finally'

2
answers

What is the finally used in PHP 5.5?

PHP 5.5 has implemented a feature (which I've heard of in other languages) called finally , in handling exceptions (along with try/catch ) We have the following example: set_error_handler(function ($errno, $errstr, $errfile, $er...
asked by 26.01.2015 / 15:42
3
answers

Is the finally block always executed in Java? [duplicate]

In this code there is a try / catch block with a return inside it. try { alguma_coisa(); return successo; } catch (Exception e) { return falha; } finally { System.out.println("Eu não sei se será possível...
asked by 24.08.2015 / 22:18
1
answer

Execution flow of a try / catch / finally block

How does the execution flow in a try/catch/finally block work in the example below? public class ExceptionTest { public static void makeException() throws ExceptionAlpha, ExceptionBeta, ExceptionGamma { throw new Exception...
asked by 02.08.2014 / 18:40
2
answers

Put method return before a "finally" block

Considering: try { System.out.println("Parte 1"); return false; } finally { System.out.println("Parte 2"); } What will be the output and what happens underneath the cloths so that the output goes out like this?     
asked by 29.11.2014 / 01:35
1
answer

How not to include the finally and still close IO Streams, Connections, Statements, and other Resources?

We know of the need to close resources (files, connections, also called resources ) consumed in Java, such as OutputStream and InputStream . When we do not close them, we create performance issues and prevent the Garbage Collector...
asked by 28.06.2015 / 17:04
0
answers

If or Try / Catch? [closed]

Here at work I came across a code that treats an error in an if instead of try / Catch. The programmer justifies that catch interrupts the code, but I believe that a Finally guarantees execution. Can you tell me what would be the best option for...
asked by 22.08.2017 / 17:04
1
answer

Put except with error name in python

I need to create a try except with two exceptions, but I do not know how to put the specific error in the first except, the error that appears below, could someone help me? raise exception_class(message, screen, stacktrace) selenium.common.ex...
asked by 05.11.2018 / 20:40