added exceptions' handler to return json on errors