G.Error
From GMod Wiki
Function | |
Syntax |
Error( String message ) Where is this used? |
Description: | |
Similar to the Msg function, this function prints text in the console. The color of the text is dependant on whether it is run on the client or server. This function will stop all functions in the call stack when it is called. | |
Returns: | nil |
Part of Library: | Global Functions |
Realm: | |
BBCode Link: | [b][url=http://wiki.garrysmod.com/?title=G.Error]G.Error [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Outputs Error to console. |
---|---|
Used on | |
Code | Error("MyScript: Failed to load necessary resources!\n") |
Output | Yellow text in the console of the client this runs on. |
Description | Outputs Error to console. |
---|---|
Used on | |
Code | Error("MyScript: Failed initialization!\n") |
Output | Blue text in the console of the server. |
Additional Notes
- Just like the Msg function, you need to end your error message with "\n" so the next message in the console isn't placed at the end of your message.
- In addition to the message you give it, this function displays the name of the file and the line number that the "Error" call was made on.
- This is only visible in the console of the system it is run on - when run on the server, only the server console sees it. When run on the client, only that client sees it.
- If run on the client, the message will be yellow in color. When run on the server, the error will be blue in color.
- The error text will also be shown on the User's HUD on the right side of his screen, just like any other Lua error message. Note that this is an unprofessional way to display information to the player and should only be used for debugging purposes.