org.springframework.expression.ExpressionException Java Examples
The following examples show how to use
org.springframework.expression.ExpressionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpelReproTests.java From java-technology-stack with MIT License | 6 votes |
private void checkTemplateParsingError(String expression, ParserContext context, String expectedMessage) { SpelExpressionParser parser = new SpelExpressionParser(); try { parser.parseExpression(expression, context); fail("Should have failed with message: " + expectedMessage); } catch (Exception ex) { String message = ex.getMessage(); if (ex instanceof ExpressionException) { message = ((ExpressionException) ex).getSimpleMessage(); } if (!message.equals(expectedMessage)) { ex.printStackTrace(); } assertThat(expectedMessage, equalTo(message)); } }
Example #2
Source File: SpelReproTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void checkTemplateParsingError(String expression, ParserContext context, String expectedMessage) throws Exception { SpelExpressionParser parser = new SpelExpressionParser(); try { parser.parseExpression(expression, context); fail("Should have failed with message: " + expectedMessage); } catch (Exception ex) { String message = ex.getMessage(); if (ex instanceof ExpressionException) { message = ((ExpressionException) ex).getSimpleMessage(); } if (!message.equals(expectedMessage)) { ex.printStackTrace(); } assertThat(expectedMessage, equalTo(message)); } }
Example #3
Source File: SpelReproTests.java From spring-analysis-note with MIT License | 5 votes |
private void checkTemplateParsingError(String expression, ParserContext context, String expectedMessage) { SpelExpressionParser parser = new SpelExpressionParser(); try { parser.parseExpression(expression, context); fail("Should have failed with message: " + expectedMessage); } catch (Exception ex) { String message = ex.getMessage(); if (ex instanceof ExpressionException) { message = ((ExpressionException) ex).getSimpleMessage(); } if (!message.equals(expectedMessage)) { ex.printStackTrace(); } assertThat(expectedMessage, equalTo(message)); } }
Example #4
Source File: PatchOperation.java From spring-sync with Apache License 2.0 | 5 votes |
/** * Retrieves a value from the operation's path. * @param target the target object. * @return the value at the path on the given target object. */ protected Object getValueFromTarget(Object target) { try { return spelExpression.getValue(target); } catch (ExpressionException e) { throw new PatchException("Unable to get value from target", e); } }
Example #5
Source File: SpelMessageInterpolator.java From spring-rest-exception-handler with Apache License 2.0 | 5 votes |
public String interpolate(String messageTemplate, Map<String, Object> variables) { Assert.notNull(messageTemplate, "messageTemplate must not be null"); try { Expression expression = parser().parseExpression(messageTemplate, new TemplateParserContext()); return expression.getValue(evalContext, variables, String.class); } catch (ExpressionException ex) { LOG.error("Failed to interpolate message template: {}", messageTemplate, ex); return ""; } }