Example usage for javax.script ScriptException getLocalizedMessage

List of usage examples for javax.script ScriptException getLocalizedMessage

Introduction

In this page you can find the example usage for javax.script ScriptException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.apache.synapse.mediators.bsf.ScriptMessageContext.java

/**
 * Returns the JavaScript Object saved in this message context.
 * @param messageContext/*from  w  w w  .  ja  v  a2  s  .  c  o  m*/
 * @return
 */
public Object jsonObject(MessageContext messageContext) {
    if (messageContext == null) {
        return null;
    }
    Object o = messageContext.getProperty(JSON_OBJECT);
    if (o == null) {
        logger.error("JSON object is null.");
        if (this.scriptEngine == null) {
            logger.error("Cannot create empty JSON object. ScriptEngine instance not available.");
            return null;
        }
        try {
            return this.scriptEngine.eval("({})");
        } catch (ScriptException e) {
            logger.error("Could not return an empty JSON object. Error>>> " + e.getLocalizedMessage());
        }
    }
    return o;
}