It's a good practice to escape your code to prevent errors from interrupting your page execution. Put your code inside a block such as this:
try { .. } catch(Throwable $e) { $e->getMessage(); }