Is it posible to throw such a business exception from ScriptCode like it was in ServiceProxy?
2 Likes
ScriptCode supports business exceptions. This can be done with method throwBusinessException(builder)
called on object context
.
Business exception is built using context.getErrorPageDefinitionBuilder()
, where it is possible to assign appropriate attributes such as:
.body(string)
.styleName(string);
.msg(string)
.pageTitle(string)
.pageTitleKey(string)
.sidebarSlot2TextContent(string);
.sidebarSlot2(string);
.sidebarSlot1TextContent(string);
.sidebarSlot1(string);
.retryButtonAvailable(string)
.retryButtonAvailable(boolean);
.logobarTitle(string);
.logobarTitleKey(string)
.logobarDescription(string);
.bodyTextContent(string);
.parameter(String key, String value)
.cause(Throwable cause)
.redirectUrl(string)
.redirectDelayInMillis(string)
.businessFormIdentifier(string)
In this case, I recommend creating a separate TextContent and passing it to the builder via .bodyTextContent(string)
Remember to include version of textconent, You can use -* to get the newest one.
Example:
function callService(context) {
var builder = context.getErrorPageDefinitionBuilder();
builder.bodyTextContent('TextContent-*');
context.throwBusinessException(builder);
return;
}
3 Likes