EyalAr / lwip

Light Weight Image Processor for NodeJS
MIT License
2.37k stars 230 forks source link

module completely crashes if file type is not image #246

Closed santhukumar closed 8 years ago

santhukumar commented 8 years ago

If the filetype passed on is not image. It just crashes without giving error. I didnt expect this and caused crash. Following is the error stack trace

/Users/santosh/Development/themeforest/ontatch/node_modules/lwip/lib/obtain.js:62
        throw Error('Unknown type \'' + ext + '\'');
                                            ^
Error: Unknown type 'numbers'
    at Error (native)
    at getOpener (/Users/santosh/Development/themeforest/ontatch/node_modules/lwip/lib/obtain.js:62:45)
    at /Users/santosh/Development/themeforest/ontatch/node_modules/lwip/lib/obtain.js:28:26
    at /Users/santosh/Development/themeforest/ontatch/node_modules/lwip/node_modules/decree/dist/cjs/decree.js:69:29
    at Object.open (/Users/santosh/Development/themeforest/ontatch/node_modules/lwip/lib/obtain.js:23:31)
    at /Users/santosh/Development/themeforest/ontatch/api/services/UtilService.js:51:12
    at cb (/Users/santosh/Development/themeforest/ontatch/node_modules/sails/node_modules/skipper/standalone/Upstream/prototype.upload.js:82:14)
    at Writable.allFilesUploaded (/Users/santosh/Development/themeforest/ontatch/node_modules/sails/node_modules/skipper/standalone/Upstream/prototype.upload.js:134:5)
    at Writable.g (events.js:199:16)
    at Writable.emit (events.js:129:20)
    at finishMaybe (_stream_writable.js:484:14)
    at afterWrite (_stream_writable.js:362:3)
    at onwrite (_stream_writable.js:352:7)
    at WritableState.onwrite (_stream_writable.js:105:5)
    at WriteStream.successfullyWroteFile (/Users/santosh/Development/themeforest/ontatch/node_modules/skipper-disk/standalone/build-disk-receiver-stream.js:117:9)
    at WriteStream.emit (events.js:129:20)
EyalAr commented 8 years ago

It's not a crash, it throws an exception, which you can catch and handle.