Skip to main content
gamedev.net
🔒 Locked

Problem catching exceptions

Started by Leadorn 5 replies 750+ views
Original Post
Leadorn
Leadorn
Hi Have you ever had problems catching exceptions, if you have, telle me about it. What pitfalls are there when using exception? I'm using c++ and I have exception classes that all inheritance from lexception. I'm using threads, but im not throwing from one thread and catching in another. I have my try block and in that i call my funktions and after the try I have my catch()
mishikel
mishikel
Quote:
Original post by Leadorn
...
I'm using threads, but im not throwing from one thread and catching in another.
...


Nor will you, since each thread has it's own stack.
Leadorn
Leadorn
Quote:
Original post by mishikel
Quote:
Original post by Leadorn
...
I'm using threads, but im not throwing from one thread and catching in another.
...


Nor will you, since each thread has it's own stack.


Someone how can read please help me.
mishikel
mishikel
You can't throw an exception in one thread and catch it in another.
flangazor
flangazor
I have had problems when the software if difficult to test (compile-run-debug cycle is long) and I used inheritence with exceptions and I end up trying to catch something that happens to be the wrong type and it wastes my time.

The solution is to either code for your projected cycle, or make sure you are throwing what you think you are throwing.
Leadorn
Leadorn
Quote:
Original post by flangazor
I have had problems when the software if difficult to test (compile-run-debug cycle is long) and I used inheritence with exceptions and I end up trying to catch something that happens to be the wrong type and it wastes my time.

The solution is to either code for your projected cycle, or make sure you are throwing what you think you are throwing.


Humm...why was is the wrong type...
LessBread
LessBread
Quote:
Original post by mishikel
You can't throw an exception in one thread and catch it in another.


That's not entirely correct. On Windows the final handler in the main thread of the process gets a crack at all unhandled exceptions. If it doesn't handle the exception, then the OS will handle it with the familiar program failure dialog box.

@Leadorn, I'm not well versed enough with C++ exceptions to properly answer your question. When I've had code that was supposed to catch exceptions but didn't, it was because the exceptions were floating point exceptions and the cpu was set to suppress fpu exceptions.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.