73 questions
5
votes
2
answers
411
views
Should I use std::rethrow_exception in my catch block, rather than directly rethrowing it?
In my code, I have something like:
try { do_stuff(); }
catch(my_exception_class& e) {
if (not can_ignore_exception(e)) {
throw e;
}
log_or_do_nothing(e);
}
A static analyzer (...
113
votes
2
answers
27k
views
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 the differences between throws and rethrows. It is kind of ...
67
votes
3
answers
104k
views
rethrowing python exception. Which to catch?
I'm learning to use python. I just came across this article:
http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html
It describes rethrowing exceptions in python, like this:
try:
...
0
votes
0
answers
52
views
Java 8, Optional. throwing Exceptions, and Re-throwing exceptions, preventing null
I have confusing (lack of comprehension) trying to translate some part of my code to Optional on Java 8.
First example mock Code
private void privateMethodOne(CustomRequesDto customRequesDto) {
...
3
votes
1
answer
1k
views
Dart: try catch not catching the exception from a function that uses 'rethrow'
I'm trying to use the library livekit_client to create a chat room, I'm trying to handle the exception when the connection fails,
this is the code I'm using to connect and catch the error:
try {
...
6
votes
1
answer
236
views
Is there a memory leak in my machine's implementation of std::exception_ptr, std::current_exception and rethrow_exception?
When running the following code, I see the memory consumption of the process grow. Is there a memory leak in my code, is there a memory leak in the std implementation, or is it intended behaviour? It'...
5
votes
1
answer
2k
views
Why do "throw" and "throw ex" have the same behavior in this case?
I'm flabbergasted. I always thought that throw by itself in a catch block would throw the exception at hand without altering the stack trace, but that throw ex in a catch block would alter the stack ...
1
vote
1
answer
1k
views
How to catch a base class constructor's exception in C++?
I have a class that is derived from another class. I want to be able to catch and re-throw the exception(s) thrown by the derived class's constructor in my derived class's constructor.
There seems to ...
144
votes
5
answers
94k
views
C++ Exceptions questions on rethrow of original exception
Will the following append() in the catch cause the rethrown exception to see the effect of append() being called?
try {
mayThrowMyErr();
} catch (myErr &err) {
err.append("Add to my message ...
0
votes
5
answers
1k
views
Flutter Image Asset cannot be shown ( image in class model )
I've made class model of places, and I want to show the logo of each place, I add the image location folder in class named place_model.dart and this is the code for place_model.dart :
class Place{
...
-1
votes
2
answers
2k
views
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 ...
0
votes
3
answers
89
views
Catching an error that I dont want to catch
Everytime I run this code, everything works fine, but if deposit methods throws an error,
only the catch in the main method catches the exception and prints the string, despite the catch in the ...
1
vote
0
answers
2k
views
Why if we return from finally, rethrow from catch not works?
Why first case prints :
"second level catch"
"top level catch"
and second case prints:
only "second level catch"?
Difference in finally block.
Future<void> main() ...
2
votes
0
answers
99
views
Any downsides to rethrowing the *cause* of a checked exception as an unchecked exception?
I am writing a library in which I use checked exceptions internally as it helps to make sure that all paths handle certain exceptional cases. However, I don't want to burden the users of my library ...
0
votes
0
answers
108
views
Try catch block doesn't catch rethrown error
UI code:
try {
authService.signInWithEmailAndPassword(
emailController.text, passwordController.text);
} catch (error) {
print("ui rethrow");
}
Auth service code:
Future<...