Always rescue exceptions when rendering

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the exceptions category.

Last Updated: 2024-03-28

I threw an unrescued exception due to data constraint errors (e.g. overbooking appointments) in a client project. This made the client think the software was broken, even though it was their way of using it that was broken.

The situation I encountered this was with Project S. The client complained that their booking system was not working properly. What I was seeing in the exception reports was

<?php
 App\Exceptions\SlotOverBookingError

I should have had generalized rescue code and used this to transform the exception name and message into something shown to the end user (that they can call me about etc.)