Hey all,
Trying to get my head around asserts vs exceptions. I read a number of threads and articles, and I'm starting to get there. One big question I have right now, though, and I figured you were the crew to throw it at. :D
Asserts, from what I understand, are debug only - correct me on that if I'm wrong. So, in a release situation, I need to use try/catch for exceptions.
Say I've got data files that the user can edit, and I want to have things bomb out if their data is bad. Frex, they can pass in a unit spec, and -1 is an invalid value for attackPower. How would I want to structure a Try block to deal with that? Would I just throw an unhandled exception?
I'm sure there are more elegant ways to deal with something like this, but I'm still trying to get my head around the inelegant way. ;) Thanks.
(Edit - Playing around with it some more, I could catch the exception, but I guess I just need to figure out the system commands that would bring everything to a halt and send the message in a nice fashion.)
Trying to get my head around asserts vs exceptions. I read a number of threads and articles, and I'm starting to get there. One big question I have right now, though, and I figured you were the crew to throw it at. :D
Asserts, from what I understand, are debug only - correct me on that if I'm wrong. So, in a release situation, I need to use try/catch for exceptions.
Say I've got data files that the user can edit, and I want to have things bomb out if their data is bad. Frex, they can pass in a unit spec, and -1 is an invalid value for attackPower. How would I want to structure a Try block to deal with that? Would I just throw an unhandled exception?
I'm sure there are more elegant ways to deal with something like this, but I'm still trying to get my head around the inelegant way. ;) Thanks.
(Edit - Playing around with it some more, I could catch the exception, but I guess I just need to figure out the system commands that would bring everything to a halt and send the message in a nice fashion.)