int getStatus(Exception e) { if (e instanceof JavaScriptException) { JavaScriptException je = (JavaScriptException) e; Object value = ((ScriptableObject) je.getValue()).get("message", null); if (value != null) { String status = Utility.find(value.toString(), "^\\d\\d\\d\\b"); if (status != null) return Integer.parseInt(status); } } return 500; }