throwing correct exception when the exception is not a Error object