Software /
code /
prosody
Comparison
plugins/mod_console.lua @ 3027:b5beb7b15ac4
mod_console: Set a chunk name for loadstring calls (nicer errors).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 07 May 2010 16:10:04 +0500 |
parent | 2923:b7049746bd29 |
child | 3028:e095d2a98936 |
child | 3043:1fadbb2e3ca0 |
comparison
equal
deleted
inserted
replaced
3026:dec4527a7499 | 3027:b5beb7b15ac4 |
---|---|
82 end | 82 end |
83 end | 83 end |
84 | 84 |
85 session.env._ = data; | 85 session.env._ = data; |
86 | 86 |
87 local chunk, err = loadstring("return "..data); | 87 local chunkname = "=console"; |
88 local chunk, err = loadstring("return "..data, chunkname); | |
88 if not chunk then | 89 if not chunk then |
89 chunk, err = loadstring(data); | 90 chunk, err = loadstring(data, chunkname); |
90 if not chunk then | 91 if not chunk then |
91 err = err:gsub("^%[string .-%]:%d+: ", ""); | 92 err = err:gsub("^%[string .-%]:%d+: ", ""); |
92 err = err:gsub("^:%d+: ", ""); | 93 err = err:gsub("^:%d+: ", ""); |
93 err = err:gsub("'<eof>'", "the end of the line"); | 94 err = err:gsub("'<eof>'", "the end of the line"); |
94 session.print("Sorry, I couldn't understand that... "..err); | 95 session.print("Sorry, I couldn't understand that... "..err); |