Question: How to catch Maple Error?

Sometimes I got an error (purple in output). How can I catch on programming level?

I mean I want to do smth like: if <error> -> then <action>

Please Wait...