Questions tagged [try-catch]
try-catch is a syntactic construct for catching exceptions raised by a code section
try-catch
8,816
questions
-1
votes
2
answers
44
views
Getting an error in console even though I have used try/catch and async/await
/* the code that is doing the API call, account.get() is an endpoint provided by Appwrite to get current user session data */
export async function getCurrentUser() {
try {
const user = await ...
1
vote
0
answers
64
views
Why is my thread blocked by this try block?
So I am self-taught and green on handling requests, but it seems to me that in the case of no request body, the BufferedReader should output null if I call .readLine() again after running this kind of ...
0
votes
2
answers
42
views
When will a laravel model creation fail without an exception?
I am adding a store method to a controller that will create and save a new model to the database using the following code:
public function store(Request $request)
{
$validated = $request->...
0
votes
1
answer
28
views
How do I get a try / exception statement to continue? [duplicate]
I need this to rerun the initial inpput question if it gets a value that is unacceptable.
try:
hours = float(input("Please enter your hours worked: "))
if hours < 1 :
...
0
votes
1
answer
41
views
Appropriate way to handle exception in Java n-tier application
I have three layers in my application Controller, Service and DAO. My controller and service layers are in spring meanwhile DAO layer is in Hibernate 6. My question is what is most appropriate way to ...
1
vote
0
answers
95
views
C++ sigbus error when trying to catch an exception
I have come across an interesting case, where C++ gives me a bus error, when I am trying to catch an exception.
I created a minimal example to reproduce the error:
#include <iostream>
using ...
-2
votes
0
answers
57
views
Ensuring a function is always called inside 'catch' block
I have a function which I always want to be called inside the 'catch' block of a try-catch statement. Is there any way in code to ensure it? Can we add some PMD checks or is it somehow possible ...
0
votes
0
answers
30
views
Nested Try/Catch alternative [duplicate]
I have a need to attempt to convert a date from the registry to a [Datetime] so that I can do operations with it, and the date format is variable, because Autodesk. I also need to be able to throw ...
0
votes
0
answers
35
views
How can I handle dead workers in R-future parallel processing
I want to fit multiple models to each participant in my data. I want to parallelize this by applying the fitting function in parallel to the data of multiple participants. For one of the models, the ...
1
vote
1
answer
74
views
How to get the current exception object in C++ Builder (replacement for ExceptObject)?
I am looking for a function/code that returns the current exception object. In other words, the exception object that represents the exception currently being handled (by the catch block).
For example:...
0
votes
0
answers
25
views
Catch block not catching file load faillure when file is blocked by applocker / wdac
try
{
var appcontrolHeartbeat = new Class1();
}
catch (FileLoadException e)
{
log.Info(
$"...
1
vote
2
answers
101
views
How to use try-catch (IOException) for BufferedWriter.write nested in if-else?
I have a block to write data(string) using BufferedWriter, but compiler keeps saying error: unreported exception IOException; must be caught or declared to be thrown this.dataContainer.stream()....
0
votes
1
answer
75
views
What does the variable declaration `const int *__errno_location ()` inside this catch statement actually do?
While working on an exercise for my C++ class where we were working on Exception handling, I came across a puzzling issue. I initially had the following exception handler (Please don't roast the use ...
-2
votes
1
answer
76
views
Why did placing my file in a try catch with a FileNotFoundException work when reading a file? [duplicate]
I got my code to work for an assignment but it doesn't help me if I don't know why it happened so I am here to try and understand by asking the community.
I am trying to read a simple text file with 3 ...
0
votes
1
answer
55
views
Variables in Try-Catch blocks with Powershell?
I have been trying to write a script in powershell that renames a file if it does not get transferred correctly through WinSCP. The script looks something like this:
# Variables
$error = 0
$...