[Closed] scripts prevented from exposing code
I’m wanting to stop an encrypted script from throwing an error and interrupting the thread thus exposing the script for inspection. It seems that no matter how many ‘try (catch)’ clauses I put in, eventually I am able to ‘break’ the script. Is there a general catch all to prevent a script ‘breaking’?
if you are having to use try/catch everywhere then you probably aren’t doing enough error checking and/or your code is poorly written. You should also debug your code unencrypted so that you can see which line(s) fail and make corrections accordingly.
ideally, post the code you are having problems with for others to see and help you debug.
Is any one here using the assert function as I have not really tried to add it to my work flow.
It’s very useful for testing. See this (sort of) unit test I wrote to (regression-)test a struct:
https://github.com/Pjanssen/Outliner/blob/develop/tests/nestedlayers_test.ms
It is of course no replacement for try/catch, it’s a different thing altogether. In fact, it will only throw more exceptions if something is wrong. I suppose you could use it to throw specific exceptions a bit more easily in ‘production code’ though, instead of using if x then throw m.
i imagine it’s designed to mirror the c\c++ function/macro and if so it’s really a debug only, obviously we don’t have a specific “debug” compile option as with c\c++, which would automatically turn it off for the release build, but i still think it’s supposed to be used in the same way, finding bugs and errors in the development stage and not for handling unforseen errors in a finished script.
Yes, that’s pretty much what I use them for… the new AssertReporter stuff in 2012 is also pretty useful. Much nicer than lot’s of print statements everywhere!
If you’re lazy you can also use the result of the assert function in an if statement to catch otherwise invalid parameters and what not and print a custom error message at the same time…