format an exception in Api.php