See [BpmError Public API about BpmError, API][1] which you also can use in Java (or IvyScript):
http://developer.axonivy.com/doc/latest/PublicAPI/ch/ivyteam/ivy/bpm/error/BpmError.htmlor IvyScript.
You could build and throw an BpmError form IvyScript or Java like this:
BpmError.create("finance:nomoney").throwError();
To find out more about this look at the error [error handling concept:concept][2] in the Designer Guide.
[1]: http://developer.axonivy.com/doc/latest/PublicAPI/ch/ivyteam/ivy/bpm/error/BpmError.html
[2]: http://developer.axonivy.com/doc/latest/DesignerGuideHtml/ivy.concepts.html#ivy-concepts-error