Exceptions in Service Builder

I am looking at trying to add custom error codes to display when users encounter issues handling data.

Example: When a user attempts to post data to the database that a business processor rule won’t allow.

I want these error codes to be in one place and easy to program with and maintain documentation on. I found the exceptions within the Service Builder, but I’m not quite sure what/how you would use them in code. Any ideas, suggestions, or example code would be very helpful.

Pls see the Mega Demo sample.
it shows usage of custom exception.