{"action":"closed","issue":{"url":"https://api.github.com/repos/grmble/node-dicom/issues/9","labels_url":"https://api.github.com/repos/grmble/node-dicom/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/grmble/node-dicom/issues/9/comments","events_url":"https://api.github.com/repos/grmble/node-dicom/issues/9/events","html_url":"https://github.com/grmble/node-dicom/issues/9","id":94878791,"number":9,"title":"how to deal with the err?","user":{"login":"KingMario","id":3956876,"avatar_url":"https://avatars.githubusercontent.com/u/3956876?v=3","gravatar_id":"","url":"https://api.github.com/users/KingMario","html_url":"https://github.com/KingMario","followers_url":"https://api.github.com/users/KingMario/followers","following_url":"https://api.github.com/users/KingMario/following{/other_user}","gists_url":"https://api.github.com/users/KingMario/gists{/gist_id}","starred_url":"https://api.github.com/users/KingMario/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KingMario/subscriptions","organizations_url":"https://api.github.com/users/KingMario/orgs","repos_url":"https://api.github.com/users/KingMario/repos","events_url":"https://api.github.com/users/KingMario/events{/privacy}","received_events_url":"https://api.github.com/users/KingMario/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-14T06:38:56Z","updated_at":"2015-07-14T11:41:19Z","closed_at":"2015-07-14T11:41:18Z","body":"dear grmble,\r\n\r\nI'm using your great library to deal with files. Some of the files are not dicom formatted, so I use the following try ... catch block, but I find that the error thrown by the library is not caught and my app just collapse with the `Unhandled 'error' event`.\r\n\r\nCould you please tell me how to handle the error thrown here. Thanks.\r\n\r\n    try {\r\n        fs.createReadStream(fileName).pipe(decoder).pipe(encoder).pipe(sink);\r\n    } catch (err) {\r\n        console.log(err);\r\n        fileHandled++;\r\n    }\r\n\r\nerr info:\r\n{\"name\":\"decoder\",\"hostname\":\"marioMacBook-Air.local\",\"pid\":1465,\"level\":50,\"error\":{},\"msg\":\"_action_wrapper:  emitting error\",\"time\":\"2015-07-14T06:30:07.222Z\",\"v\":0}\r\nevents.js:85\r\n      throw er; // Unhandled 'error' event\r\n            ^\r\nError: Unable to guess DICOM encoding\r\n    at DicomError.Error (native)\r\n    at new DicomError (/Users/Mario/work/sysyunshung/ufop/New Spec/zufop/node_modules/dicom/lib/vrs.js:17:47)\r\n    at Decoder._guess_header (/Users/Mario/work/sysyunshung/ufop/New Spec/zufop/node_modules/dicom/lib/decoder.js:250:13)\r\n    at /Users/Mario/work/sysyunshung/ufop/New Spec/zufop/node_modules/dicom/lib/decoder.js:4:61\r\n    at Decoder._action_wrapper (/Users/Mario/work/sysyunshung/ufop/New Spec/zufop/node_modules/dicom/lib/decoder.js:205:16)\r\n    at Decoder._transform (/Users/Mario/work/sysyunshung/ufop/New Spec/zufop/node_modules/dicom/lib/decoder.js:80:12)\r\n    at Decoder.Transform._read (_stream_transform.js:179:10)\r\n    at Decoder.Transform._write (_stream_transform.js:167:12)\r\n    at doWrite (_stream_writable.js:301:12)\r\n    at writeOrBuffer (_stream_writable.js:288:5)\r\n"}}