about summary refs log tree commit diff stats
path: root/app.lua
diff options
context:
space:
mode:
Diffstat (limited to 'app.lua')
-rw-r--r--app.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/app.lua b/app.lua
index 8068e3f..a2f1f78 100644
--- a/app.lua
+++ b/app.lua
@@ -43,7 +43,8 @@ function love.run()
 end
 
 function handle_error(err)
-  Error_message = debug.traceback('Error: ' .. tostring(err), --[[stack frame]]2)
+  local callstack = debug.traceback('', --[[stack frame]]2)
+  Error_message = 'Error: ' .. tostring(err)..'\n'..clean_up_callstack(callstack)
   print(Error_message)
   if Current_app == 'run' then
     Settings.current_app = 'source'
@@ -56,6 +57,26 @@ function handle_error(err)
   end
 end
 
+-- I tend to read code from files myself (say using love.filesystem calls)
+-- rather than offload that to load().
+-- Functions compiled in this manner have ugly filenames of the form [string "filename"]
+-- This function cleans out this cruft from error callstacks.
+function clean_up_callstack(callstack)
+  local frames = {}
+  print(callstack)
+  for frame in string.gmatch(callstack, '[^\n]+\n*') do
+    local line = frame:gsub('^%s*(.-)\n?$', '%1')
+    local filename, rest = line:match('([^:]*):(.*)')
+    local core_filename = filename:match('^%[string "(.*)"%]$')
+    -- pass through frames that don't match this format
+    -- this includes the initial line "stack traceback:"
+    local new_frame = (core_filename or filename)..':'..rest
+    table.insert(frames, new_frame)
+  end
+  -- the initial "stack traceback:" line was unindented and remains so
+  return table.concat(frames, '\n\t')
+end
+
 -- The rest of this file wraps around various LÖVE primitives to support
 -- automated tests. Often tests will run with a fake version of a primitive
 -- that redirects to the real love.* version once we're done with tests.
2016-02-10 21:38:28 +0000 Added mention and trigger themes for console' href='/danisanti/profani-tty/commit/themes/whiteness?id=71679a3159037c353656b19e3b36ab303714bc15'>71679a31 ^
45a26b11 ^


45a26b11 ^
30b5f112 ^
2f82f50a ^
86c1c388 ^
1a3dc91e ^
30b5f112 ^


fbc30231 ^

















cd2458c0 ^

0ae975c2 ^

b21edfaa ^
1900402f ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78