Jump to content

Recommended Posts

Hey all,

 

First of all, I want to apologize in advance if this is not the right place to throw this question at.

 

Now, to the question itself. I have recently started doing a wee bit of scripting to implement some utility scripts for me and friends. I have been trying to make them as generic as possible and now I have been at the point that I want to find a way to handle "incorrect" arguments (either wrong type, nonsensical numbers, null objects, etc.). I do have a bit of programming background and having utilized "try, catch, throw" exception facilities of other programming languages before I wanted to check it here too.

 

So far I have seen absolutely no one using them and in the documentation I read that scripting commands in ArmA do not throw exceptions. So, I was wondering if it would be a good idea to use "throws" in my scripts or not, since the majority of the users "never" use try-catch blocks.

 

I would really like to hear opinions on the matter or even "aggressive" statements either against or in support of this specific facility/construct.

 

Hope to hear from you.

 

Have fun, take care and ArmA a lot,

 

Achilles.

Share this post


Link to post
Share on other sites

params and param already have build in mechanics to prevent incorrect arguments, plus there are a bunch of commands that will let you check types quietly, so you could handroll own handling

  • Like 2

Share this post


Link to post
Share on other sites
1 hour ago, killzone_kid said:

params and param already have build in mechanics to prevent incorrect arguments, plus there are a bunch of commands that will let you check types quietly, so you could handroll own handling

absolutely true

 

for arguments u need params only and sometimes typeName is usefull.

Share this post


Link to post
Share on other sites

Hey thanks both of your for the answers.

 

I am already familiar with both commands but I am kinda thinking whether it is preferred to throw when something is wrong or maybe do nothing exitWith and sent a message (either hint, systemChat, diag_log or something like this).

 

As I said, so far, I have yet to meet someone using the exception handling alternative in ArmA, so I guess it won't really add anything useful if instead of doing my own handling (like killzone_kid suggests) I use the already implemented ArmA's exception handling. This is why I actually posted this question.

 

So, I guess there is not point (in the sense that there is no generality added, or it is safer in any way) using the built-in exception handling against taking care of the possible "errors" (nonsensical arguments, incorrect type, etc.) myself and (possibly, or optionally) informing the user.

 

Thanks for expressing your opinion and for the insight.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×