Pomax / lib-font

This library adds a new Font() object to the JavaScript toolbox, similar to new Image() for images
MIT License
731 stars 72 forks source link

Move throwing of exceptions #12

Closed bjarneheden closed 11 years ago

bjarneheden commented 12 years ago

I moved the throwing of exceptions for Object.defineProperty and canvas to the Font constructor to make it possible to actually catch the exception/s and act on it (e.g. use fallback solution for older IE).

Pomax commented 11 years ago

I'd rather return early; if the code throws on load, no calls to anything related to Font.js will ever work, which is good ("if it's going to be broken, don't try to use parts of it"). Moving the throws into the constructor rather than keeping them as a load requirement will execute code that is guaranteed to never succeed, wasting time and creating a longer than necessary callstack trace.