mirror of https://github.com/Hilbis/Hilbish
feat: print command errors via hook
this allows users to remove the handlers and print a custom message to their likingpull/215/merge
parent
6ca36847f1
commit
0a49e1a4ef
4
exec.go
4
exec.go
|
@ -141,10 +141,10 @@ func runInput(input string, priv bool) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if exErr, ok := isExecError(err); ok {
|
if exErr, ok := isExecError(err); ok {
|
||||||
hooks.Emit("command." + exErr.typ, exErr.cmd)
|
hooks.Emit("command." + exErr.typ, exErr.cmd)
|
||||||
err = exErr.sprint()
|
} else {
|
||||||
}
|
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
cmdFinish(exitCode, input, priv)
|
cmdFinish(exitCode, input, priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,3 +69,11 @@ end
|
||||||
bait.catch('error', function(event, handler, err)
|
bait.catch('error', function(event, handler, err)
|
||||||
bait.release(event, handler)
|
bait.release(event, handler)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
bait.catch('command.not-found', function(cmd)
|
||||||
|
print(string.format('hilbish: %s not found', cmd))
|
||||||
|
end)
|
||||||
|
|
||||||
|
bait.catch('command.not-executable', function(cmd)
|
||||||
|
print(string.format('hilbish: %s: not executable', cmd))
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue