diff --git a/Zframework/file.lua b/Zframework/file.lua index 33f4f255..99acdda9 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -50,7 +50,7 @@ function FILE.save(data,name,mode) F:flush()F:close() if not success then MES.new('error',text.saveError..(mes or"unknown error")) - MES.new(false,debug.traceback()) + MES.traceback(1) end return success end diff --git a/Zframework/json.lua b/Zframework/json.lua index bfa85f15..ba13ad9f 100644 --- a/Zframework/json.lua +++ b/Zframework/json.lua @@ -118,8 +118,8 @@ function json.encode(val) local a,b=pcall(encode,val) if a then return b - elseif MES.new then - MES.new('error',text.jsonError..": "..(b or"uknErr")) + elseif MES then + MES.traceback(1) end end @@ -348,8 +348,8 @@ function json.decode(str) local a,b=pcall(decode,str) if a then return b - elseif MES.new then - MES.new('error',text.jsonError..": "..(b or"uknErr")) + elseif MES then + MES.traceback(1) end end return json \ No newline at end of file diff --git a/Zframework/message.lua b/Zframework/message.lua index aed24b7c..dee9113a 100644 --- a/Zframework/message.lua +++ b/Zframework/message.lua @@ -63,7 +63,7 @@ function MES.new(icon,str,time) if type(icon)=='string'then icon=mesIcon[icon]end local t=gc.newText(getFont(30),str) local w=math.max(t:getWidth()+(icon and 45 or 5),200)+20 - local h=math.max(t:getHeight(),46) + local h=math.max(t:getHeight(),46)+3 local L={w,h, {'clear',.5,.5,.5,.7}, {'setCL',.7,.7,.7}, @@ -114,4 +114,17 @@ function MES.draw() end gc_pop() end + +function MES.traceback(n) + local mes= + debug.traceback("",(n or 1)+1) + :gsub(": in function",", in") + :gsub(":"," ") + :gsub("\t","") + MES.new('error',mes:sub( + mes:find("\n",2)+1, + mes:find("\n%[C%], in 'xpcall'") + ),5) +end + return MES \ No newline at end of file