{"action":"created","issue":{"url":"https://api.github.com/repos/garrynewman/garrysmod/issues/931","labels_url":"https://api.github.com/repos/garrynewman/garrysmod/issues/931/labels{/name}","comments_url":"https://api.github.com/repos/garrynewman/garrysmod/issues/931/comments","events_url":"https://api.github.com/repos/garrynewman/garrysmod/issues/931/events","html_url":"https://github.com/garrynewman/garrysmod/pull/931","id":70229926,"number":931,"title":"Expand OnLuaError to all realms","user":{"login":"Exho1","id":8472757,"avatar_url":"https://avatars.githubusercontent.com/u/8472757?v=3","gravatar_id":"","url":"https://api.github.com/users/Exho1","html_url":"https://github.com/Exho1","followers_url":"https://api.github.com/users/Exho1/followers","following_url":"https://api.github.com/users/Exho1/following{/other_user}","gists_url":"https://api.github.com/users/Exho1/gists{/gist_id}","starred_url":"https://api.github.com/users/Exho1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Exho1/subscriptions","organizations_url":"https://api.github.com/users/Exho1/orgs","repos_url":"https://api.github.com/users/Exho1/repos","events_url":"https://api.github.com/users/Exho1/events{/privacy}","received_events_url":"https://api.github.com/users/Exho1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-22T20:42:34Z","updated_at":"2015-04-22T20:47:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/garrynewman/garrysmod/pulls/931","html_url":"https://github.com/garrynewman/garrysmod/pull/931","diff_url":"https://github.com/garrynewman/garrysmod/pull/931.diff","patch_url":"https://github.com/garrynewman/garrysmod/pull/931.patch"},"body":"This takes the OnLuaError hook, which currently is only available in the menu realm, and allows it to be called in the client/server realms as well. Its been requested before (https://github.com/Facepunch/garrysmod-requests/issues/149) but for the most part ignored since I figure a good solution would require modifying it in Garry's mod's source. So this is a solution that I've heard from Meep and MDave on seperate occasions. Obviously this hook doesn't return anything like stopping the actual error function from being called because that is prone to abuse. Lastly this differs from the menu calling of the hook because it omits the last 2 arguments but actually uses the second argument (1 for Client 0 for Server). \r\n\r\nThis would allow developers to track whenever a Lua error occurs, without wrapping everything in PCalls, and run functions for that. I planned on using something like this in my gPhone so I could dump a log of all the gPhone events to a text file whenever a Lua error occured to help replicate bugs but never got around to it. I don't think the uses are limited to that. \r\n\r\nExample:\r\n\r\n    hook.Add(\"OnLuaError\", \"errortest\", function( error, realm, name, id )\r\n        if realm == 1 then\r\n            print(\"Client\", error)\r\n        else\r\n            print(\"Server\", error)\r\n        end\r\n    end)\r\n\r\n>Client\taddons/exho scrap/lua/scraparmor/cl_inventory.lua:23: attempt to index global 'frame' (a nil value)\r\n\r\n>[ERROR] addons/exho scrap/lua/scraparmor/cl_inventory.lua:23: attempt to index global 'frame' (a nil >value)\r\n>  1. __index - addons/exho scrap/lua/autorun/scrap_adder.lua:30\r\n>   2. unknown - addons/exho scrap/lua/scraparmor/cl_inventory.lua:23\r\n>    3. unknown - lua/includes/modules/concommand.lua:54\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/garrynewman/garrysmod/issues/comments/95329847","html_url":"https://github.com/garrynewman/garrysmod/pull/931#issuecomment-95329847","issue_url":"https://api.github.com/repos/garrynewman/garrysmod/issues/931","id":95329847,"user":{"login":"wiox","id":1499676,"avatar_url":"https://avatars.githubusercontent.com/u/1499676?v=3","gravatar_id":"","url":"https://api.github.com/users/wiox","html_url":"https://github.com/wiox","followers_url":"https://api.github.com/users/wiox/followers","following_url":"https://api.github.com/users/wiox/following{/other_user}","gists_url":"https://api.github.com/users/wiox/gists{/gist_id}","starred_url":"https://api.github.com/users/wiox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wiox/subscriptions","organizations_url":"https://api.github.com/users/wiox/orgs","repos_url":"https://api.github.com/users/wiox/repos","events_url":"https://api.github.com/users/wiox/events{/privacy}","received_events_url":"https://api.github.com/users/wiox/received_events","type":"User","site_admin":false},"created_at":"2015-04-22T20:47:51Z","updated_at":"2015-04-22T20:47:51Z","body":"The last thing I can see getting accepted is a solution as hacky as this."}}