Assert question?
BlitzMax Forums/BlitzMax Beginners Area/Assert question?
| ||
Hi, The Assert command has two different styles of usage. In the 'Language Reference' it says: Assert alpha>=0 And alpha<=1 Else "Alpha value out of range"And in the 'Module Reference' it says: Assert a,"Image Failed to Load"Are there any differences or are they just alternatives to each other? |
| ||
Just alternatives. |
| ||
Ok, thanks! On a related note is it possible to register an 'error class' so that instead of saying: 'Unhandled Exception' the output window could say for example: 'My Super Module Exception'. That might make it easier to quickly find out where and what went wrong. Is this done by making an extension to the TBlitzException Type? (Perhaps it isn't a Beginners Area question anymore) |
| ||
Hi, No quite sure what you mean, but... 'Unhandled Exception' means that there was no active 'Try/Catch' block to catch the exception, which is when the debugger kicks in, or the app quits if there's no debugger. You can bypass this by installing a 'root' Try/Catch handler, eg: '----main.bmx---- Try RunMyApp() Catch ex:Object Print ex.ToString() End Try This will catch *all* exceptions, and the debugger will never be invoked. You can create your own exception types: Type MyEx Method ToString$() blah End Method End Type Try RunMyApp() Catch ex:MyEx 'MyApp caused a MyEx exception Print "MyEx thrown:"+ex.ToString() Catch ex:Object 'MyApp caused a non-MyEx exception Print "Unknown thrown:"+ex.ToString() End Try ...To throw a MyEx, use 'Throw New MyEx' |
| ||
Ah, ok, I think I understand it now. Thank you! |