danbuis / BBDGamesLib

Code base to rapidly make Java based programs using OpenGL to render to the screen
0 stars 0 forks source link

Explore the removal of the exception thrown by Engine.constructor #80

Closed danbuis closed 4 years ago

danbuis commented 4 years ago

Its never thrown. Its not clear why it is in there. Maybe we can remove it.

danbuis commented 4 years ago

Nope, looks like we gotta keep it in some capacity due to resource loading. I'm going to try to keep it local instead of propogating the exception up.

danbuis commented 4 years ago

Used some try/catch blocks to prevent exceptions from propagating up.

Got a nice reminder on exceptions that I'll leave here for posterity. Basically exceptions have to be caught at some point, if there is not an explicit try/catch block when it is thrown than the next method on the stack needs to know that it might have an exception incoming at some point. This is what had happened prior. No one was catching the exception so it propagated all the way to the bottom of the stack, the Engine class.

Now we are catching the exceptions locally, leading to cleaner method signatures in a lot of other places. Since there are so many exceptions possible in the shader class, I'm letting the user implementing class handle them in case they want to have some funky retry or default type logic. In the example game I'm just wrapping things in a simple try/catch with no bells or whistles.