Add instanceof check for inheriting from Error

* instanceof is faster so put it first:
  http://jsperf.com/error-instanceof-performance