mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 17:59:30 +00:00
Improve error handling
This commit is contained in:
parent
d68c6fab0d
commit
81f5f8fbbb
3 changed files with 296 additions and 257 deletions
14
bin/can
14
bin/can
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env lua
|
||||
|
||||
local candran = require("candran")
|
||||
local candran = require("candran").setup()
|
||||
local cmdline = require("candran.cmdline")
|
||||
|
||||
local args = cmdline(arg)
|
||||
|
|
@ -27,7 +27,11 @@ if arg[#arg] == "-" then
|
|||
io.stderr:write("can: "..err.."\n")
|
||||
os.exit(1)
|
||||
end
|
||||
f()
|
||||
local r, e = xpcall(f, candran.messageHandler)
|
||||
if not r then
|
||||
io.stderr:write(e.."\n")
|
||||
os.exit(1)
|
||||
end
|
||||
-- file
|
||||
elseif #args >= 1 then
|
||||
local f, err = candran.loadfile(args[1], nil, args)
|
||||
|
|
@ -35,7 +39,11 @@ elseif #args >= 1 then
|
|||
io.stderr:write("can: "..err.."\n")
|
||||
os.exit(1)
|
||||
else
|
||||
f()
|
||||
local r, e = xpcall(f, candran.messageHandler)
|
||||
if not r then
|
||||
io.stderr:write(e.."\n")
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
-- REPL
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue