feat: print on unhandled err case for fs.cd

pull/59/head
sammyette 2021-05-19 17:00:23 -04:00
parent 14e6ae5a3c
commit 9f1ad83c51
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package fs
import (
"fmt"
"os"
"strings"
@ -31,9 +32,13 @@ func cd(L *lua.LState) int {
err := os.Chdir(strings.TrimSpace(path))
if err != nil {
switch err.(*os.PathError).Err.Error() {
switch e := err.(*os.PathError).Err.Error(); e {
case "no such file or directory":
LuaErr(L, 1)
default:
fmt.Printf("Found unhandled error case: %s", e)
fmt.Printf("Report this at https://github.com/Hilbis/Hilbish/issues with the title being: \"fs: unahndled error case %s\", and show what caused it.\n", e)
LuaErr(L, 213)
}
}