Use $.error() instead of throw; reformat code