angular-dynamic-layout icon indicating copy to clipboard operation
angular-dynamic-layout copied to clipboard

When throwing errors Error object should be used

Open borntorun opened this issue 10 years ago • 1 comments

When throwing errors I think the Error object should be used instead of just throwing a message string:

Instead of this: position.service.js .... if (item.columnSpan > colHeights.length) { throw 'Item too large'; } ...

an Error object should be thrown: ... if (item.columnSpan > colHeights.length) { throw new Error('Item too large'); } ...

When throwing just string any code that handles exception will receive a string and not as expected an Error object.

borntorun avatar Nov 17 '15 17:11 borntorun

Yes that is better practice

tristanguigue avatar Nov 21 '15 13:11 tristanguigue