diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-03-21 12:13:30 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-03-21 12:13:30 +0800 |
| commit | 3bb3036f12247bd87afdf81dfef7e695c8fe3528 (patch) | |
| tree | 1f60cbc5301b71ac9bf0b2faebf2b2364205187b /src/MoonP/stacktraceplus.h | |
| parent | d0adaf086d91f600f497c6e267a3623f3cb9012e (diff) | |
| download | yuescript-3bb3036f12247bd87afdf81dfef7e695c8fe3528.tar.gz yuescript-3bb3036f12247bd87afdf81dfef7e695c8fe3528.tar.bz2 yuescript-3bb3036f12247bd87afdf81dfef7e695c8fe3528.zip | |
clean up.
Diffstat (limited to '')
| -rw-r--r-- | src/MoonP/stacktraceplus.h | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/src/MoonP/stacktraceplus.h b/src/MoonP/stacktraceplus.h index a309578..fcd887a 100644 --- a/src/MoonP/stacktraceplus.h +++ b/src/MoonP/stacktraceplus.h | |||
| @@ -358,7 +358,7 @@ end | |||
| 358 | -- @param message An optional error string or object. | 358 | -- @param message An optional error string or object. |
| 359 | -- @param level An optional number telling at which level to start the traceback (default is 1) | 359 | -- @param level An optional number telling at which level to start the traceback (default is 1) |
| 360 | -- | 360 | -- |
| 361 | -- Returns a string with the stack trace and a string with the original error. | 361 | -- Returns a string with the stack trace. |
| 362 | -- | 362 | -- |
| 363 | function _M.stacktrace(thread, message, level) | 363 | function _M.stacktrace(thread, message, level) |
| 364 | if type(thread) ~= "thread" then | 364 | if type(thread) ~= "thread" then |
| @@ -389,26 +389,16 @@ function _M.stacktrace(thread, message, level) | |||
| 389 | dumper:add("\r\n}") | 389 | dumper:add("\r\n}") |
| 390 | elseif type(message) == "string" then | 390 | elseif type(message) == "string" then |
| 391 | local fname, line, msg = message:match('(.+):(%d+): (.*)$') | 391 | local fname, line, msg = message:match('(.+):(%d+): (.*)$') |
| 392 | local nfname, nline, nmsg = fname:match('(.+):(%d+): (.*)$') | 392 | if fname then |
| 393 | if nfname then | 393 | local nfname, nline, nmsg = fname:match('(.+):(%d+): (.*)$') |
| 394 | fname = nmsg | 394 | if nfname then |
| 395 | fname = nmsg | ||
| 396 | end | ||
| 395 | end | 397 | end |
| 396 | if fname then | 398 | if fname then |
| 397 | fname = fname:gsub("%[string \"", "") | 399 | fname = fname:gsub("%[string \"", "") |
| 398 | fname = fname:gsub("\"%]", "") | 400 | fname = fname:gsub("\"%]", "") |
| 399 | fname = fname:gsub("^%s*(.-)%s*$", "%1") | 401 | fname = fname:gsub("^%s*(.-)%s*$", "%1") |
| 400 | local extension = fname:match("%.([^%.\\/]*)$") | ||
| 401 | if not extension then | ||
| 402 | local fext = fname .. ".lua" | ||
| 403 | if moonp.file_exist(fext) then | ||
| 404 | fname = fext | ||
| 405 | else | ||
| 406 | fext = fname .. ".moon" | ||
| 407 | if moonp.file_exist(fext) then | ||
| 408 | fname = fext | ||
| 409 | end | ||
| 410 | end | ||
| 411 | end | ||
| 412 | fname, line = getMoonLineNumber(fname, line) | 402 | fname, line = getMoonLineNumber(fname, line) |
| 413 | if _M.simplified then | 403 | if _M.simplified then |
| 414 | message = table.concat({ | 404 | message = table.concat({ |
| @@ -425,13 +415,6 @@ function _M.stacktrace(thread, message, level) | |||
| 425 | dumper:add(message) | 415 | dumper:add(message) |
| 426 | end | 416 | end |
| 427 | 417 | ||
| 428 | local moonp = require("moonp") | ||
| 429 | if moonp._hide_stacktrace_ then | ||
| 430 | local msg = dumper:concat_lines() | ||
| 431 | moonp._hide_stacktrace_ = nil | ||
| 432 | return message | ||
| 433 | end | ||
| 434 | |||
| 435 | dumper:add("\r\n") | 418 | dumper:add("\r\n") |
| 436 | dumper:add[[ | 419 | dumper:add[[ |
| 437 | Stack Traceback | 420 | Stack Traceback |
| @@ -448,20 +431,7 @@ Stack Traceback | |||
| 448 | elseif info.what == "main" or info.what == "Lua" then | 431 | elseif info.what == "main" or info.what == "Lua" then |
| 449 | info.source = info.source | 432 | info.source = info.source |
| 450 | end | 433 | end |
| 451 | local fname = info.source | 434 | info.source, info.currentline = getMoonLineNumber(info.source, info.currentline) |
| 452 | local extension = fname:match("%.([^%.\\/]*)$") | ||
| 453 | if not extension then | ||
| 454 | local fext = fname .. ".lua" | ||
| 455 | if moonp.file_exist(fext) then | ||
| 456 | fname = fext | ||
| 457 | else | ||
| 458 | fext = fname .. ".moon" | ||
| 459 | if moonp.file_exist(fext) then | ||
| 460 | fname = fext | ||
| 461 | end | ||
| 462 | end | ||
| 463 | end | ||
| 464 | info.source, info.currentline = getMoonLineNumber(fname, info.currentline) | ||
| 465 | if info.what == "main" then | 435 | if info.what == "main" then |
| 466 | if _M.simplified then | 436 | if _M.simplified then |
| 467 | dumper:add_f("(%d) '%s':%d\r\n", level_to_show, info.source, info.currentline) | 437 | dumper:add_f("(%d) '%s':%d\r\n", level_to_show, info.source, info.currentline) |
