dicomParser icon indicating copy to clipboard operation
dicomParser copied to clipboard

Don't throw object, throw Error

Open cancan101 opened this issue 8 years ago • 5 comments

Right now we have:

            catch(e) {
                var ex = {
                    exception: e,
                    dataSet: dataSet
                };
                throw ex;
            }

which leave this in the console:

dicomParser.js:157 Uncaught [object Object]

see: http://eslint.org/docs/rules/no-throw-literal

cancan101 avatar May 10 '16 22:05 cancan101

I agree exceptions should use Error but am concerned that changing this is not backwards compatible. Perhaps we do this in 2.0 or add an options flag to optionally enable this behavior?

chafey avatar May 20 '16 13:05 chafey

I started using promises to wrap this and dump out the promise chain error, it actually returns the data if that helps at all.

jkrot avatar Jun 17 '16 18:06 jkrot

I haven't forgotten about this but it is a breaking change to the API so will have to wait until the 2.0 release

chafey avatar Sep 08 '16 03:09 chafey

+1 on this, was rather surprised to get an object containing the full DataSet as UInt8Array logged in an error handler. Happy to help if version 2.0 is planned.

kmannislands avatar Sep 14 '22 20:09 kmannislands

Forward backward compatibility pre-2.0, you could introduce some global setting that controls how exceptions are raised and potentially prints a deprecation warning when the default (old style) is in use.

cancan101 avatar Sep 15 '22 02:09 cancan101