Top "Try-catch" questions

try-catch is a syntactic construct for catching exceptions raised by a code section

writing a JUnit Test case for custom checked exception in Java?

I am writing a test case for my class that has methods which throw exceptions (both checked and runtime). I …

java exception try-catch junit4 checked-exceptions
catch exception by pointer in C++

I found that there are three ways to catch an exception, what are the differences? 1) catch by value; 2) catch by …

c++ exception-handling throw try-catch
How do I close a file after catching an IOException in java?

All, I am trying to ensure that a file I have open with BufferedReader is closed when I catch an …

java exception-handling try-catch ioexception bufferedreader
Try-catch every line of code without individual try-catch blocks

I do not currently have this issue, but you never know, and thought experiments are always fun. Ignoring the obvious …

c# try-catch expression-trees
Return in try & catch versus return in finally?

Is either one of these risky? Is one better? Or is it one of those things you print out and …

c# try-catch return finally
Are destructors called after a throw in C++?

I ran a sample program and indeed destructors for stack-allocated objects are called, but is this guaranteed by the standard?

c++ exception-handling try-catch raii
Throw Exception VS Return Error within a Try,Catch,Finally

I'm pretty sure I already know the answer, but I'm still curious what the opinion is on handling an error …

exception try-catch try-catch-finally
Is the try-catch-finally block synchronous in node.js?

I have some code runing in a child process in a node program like so: try{ var data = fs.readFileSync(…

node.js asynchronous try-catch child-process
What are the differences between throws and rethrows in Swift?

After searching for some references to figure it out, -unfortunately- I could not find useful -and simple- description about understanding …

swift error-handling try-catch throws rethrow
Pattern to avoid nested try catch blocks?

Consider a situation where I have three (or more) ways of performing a calculation, each of which can fail with …

c# design-patterns try-catch monads