#!/bin/bash -e
 
trap "echo ERROR HANDLING HERE." ERR
echo "Starting" 
asdfasdf
echo "End"

And when you run it:

Starting
piet.sh: line 5: asdfasdf: command not found
ERROR HANDLING HERE.
End