The `catch-block` in a program is used to handle an `exception` thrown by a block of code.
Questions tagged [catch-block]
144 questions
-1
votes
2 answers
fetch() not catching custom error message
I have the following fetch() api but the catch blocks aren't working correctly. The error message I get is:
SyntaxError: Unexpected token < in JSON at position 0 undefined
but what I'm expecting is:
something went wrong null
here's the api:
const…

DCR
- 14,737
- 12
- 52
- 115
-1
votes
1 answer
Access AWS step function error in lambda (Python) code
I used this link to include the previous state and error details in the "catch" block for a state in AWS step function :
https://docs.aws.amazon.com/step-functions/latest/dg/input-output-resultpath.html#input-output-resultpath-catch
And I am able to…

Indi
- 1,401
- 13
- 30
-1
votes
2 answers
throw checked exception as unchecked in java instead of wrapping
I have the following code and i need to scan the Exception thrown. If it satisfies a particular condition i ignore the exception. Else i re-throw. The exception being thrown is a checked exception that means re-throwing is the hard part. Including…

D. Sikilai
- 467
- 1
- 3
- 17
-1
votes
1 answer
How write Unit test in Catch block in Xunit?
In the following function, I want to test the case where an exception is thrown using XUnit. The test should verify that the excpetion is correctly thrown.
public IDictionary Build(string content)
{
try
{
var settings…
-1
votes
1 answer
Code in "catch" block not executing
please help me understand why:) My program reach the "try" line, but seems to skip the "catch", Although its printing the stacktrace...
I'm using JOptionPane in my catch, but also System.out.println() not working.
Code:
import…

Erez
- 502
- 3
- 6
- 17
-1
votes
1 answer
Is there a way to determine if an recipient email address is invalid
With the mailing application I'm working on, I catch SendFailedException to handle validation of recipient email addresses. After reading a bit more though, I learned that catch blocks are quite expensive. It made me wonder if there was any way to…

user3643117
- 20
- 4
-2
votes
3 answers
Is there a cleaner way to do this in Java try-catch?
try
{
try
{
function(a, b);
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
}
catch (Exception e)
{
System.out.println("---------------------------------");
}
I do this nested try-catch…

Khaled.K
- 5,828
- 1
- 33
- 51
-4
votes
1 answer
How to debug try and catch blocks?
I was wondering if there is someone that can help me out with these two debugging assignments in Java, involving try/catch/throw statements. I can't seem to figure out how to debug either assignment working in NetBeans Zip file is attached.
All or…

Hayden Weinger
- 1
- 1
- 1
-5
votes
1 answer
Will catch statement be executed if try statement is running fine?
I have written some code in try statement and during debugging,the code is working fine.
But after try statement, control is moving to catch statement and it is throwing Null Pointer Exception. Here is the code:-

Rodger Nadal
- 309
- 2
- 8
- 21