Handle EACCES errors

This commit is contained in:
Juan Cruz Viotti 2015-01-20 15:09:26 -04:00
parent af7a40bd68
commit da02857a6e
2 changed files with 10 additions and 0 deletions

View File

@ -12,6 +12,9 @@ exports.handle = (error, exit = true) ->
else if error.code is 'ENOENT'
console.error("No such file or directory: #{error.path}")
else if error.code is 'EACCES'
console.error('You don\'t have enough privileges to run this operation.')
else if error.message?
console.error(error.message)

View File

@ -77,3 +77,10 @@ describe 'Errors:', ->
checkProcessExitOption error, false, (processExitStub, logErrorStub) ->
expect(logErrorStub).to.have.been.calledOnce
expect(logErrorStub).to.have.been.calledWith('No such file or directory: hello')
it 'should handle EACCES', ->
error = new Error()
error.code = 'EACCES'
checkProcessExitOption error, false, (processExitStub, logErrorStub) ->
expect(logErrorStub).to.have.been.calledOnce
expect(logErrorStub).to.have.been.calledWith('You don\'t have enough privileges to run this operation.')