Yes, error()
is similar to print()
, but instead of displaying a message in Output , it throws an error with the string passed to it. You can call the method like so:
1 | error ( "Hello, this is an error." ) |
Which can be useful for some reasons, like if the script gets to a point it shouldn't.
Use that line from a Command Line or from a script to see an output similar to this:
Command Line:
1 | 21 : 33 : 08.172 - error ( "This is an error message" ): 1 : This is an error message |
2 | 21 : 33 : 08.173 - Script 'error("This is an error message")' , Line 1 |
3 | 21 : 33 : 08.174 - Stack End |
Script:
1 | // I called the error method like this: |
4 | 21 : 36 : 02.645 - Workspace.Script: 1 : HELLO |
5 | 21 : 36 : 02.646 - Script 'Workspace.Script' , Line 1 |
6 | 21 : 36 : 02.648 - Stack End |