-
Notifications
You must be signed in to change notification settings - Fork 744
How am I suppose to handle errors with ShellJS? #707
Copy link
Copy link
Closed
Labels
fixBug/defect, or a fix for such a problemBug/defect, or a fix for such a problem
Description
Node: v7.9.0
ShellJS: 0.7.7
OS: Windows 10 (with Ubuntu Bash)
I'm trying to cat a directory (which should obviously fail) but I want to catch the error instead of exiting my program altogether but try/catch doesn't seem to work:
function cat(path) {
try {
return shx.cat(path); // Completely exists the program when fails.
} catch(e) {
return "Error";
}
}Error on exit:
ShellJS: internal error
Error: EISDIR: illegal operation on a directory, read
at Object.fs.readSync (fs.js:682:19)
at tryReadSync (fs.js:480:20)
at Object.fs.readFileSync (fs.js:517:19)
at /mnt/d/nou/ContentAPI/node_modules/shelljs/src/cat.js:35:15
at Array.forEach (native)
at Object._cat (/mnt/d/nou/ContentAPI/node_modules/shelljs/src/cat.js:30:9)
at Object.cat (/mnt/d/nou/ContentAPI/node_modules/shelljs/src/common.js:383:25)
at cat (/mnt/d/nou/ContentAPI/ContentAPI.js:78:16)
at Object.<anonymous> (/mnt/d/nou/ContentAPI/ContentAPI.js:27:24)
at Generator.next (<anonymous>)
at onFulfilled (/mnt/d/nou/ContentAPI/node_modules/co/index.js:65:19)
at /mnt/d/nou/ContentAPI/node_modules/co/index.js:54:5
at Object.co (/mnt/d/nou/ContentAPI/node_modules/co/index.js:50:10)
at Object.toPromise (/mnt/d/nou/ContentAPI/node_modules/co/index.js:118:63)
at next (/mnt/d/nou/ContentAPI/node_modules/co/index.js:99:29)
at onFulfilled (/mnt/d/nou/ContentAPI/node_modules/co/index.js:69:7)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixBug/defect, or a fix for such a problemBug/defect, or a fix for such a problem