List of usage examples for com.google.gwt.user.server.rpc RPCServletUtils isExpectedException
public static boolean isExpectedException(Method serviceIntfMethod, Throwable cause)
From source file:com.brightedu.server.util.MyRPC.java
License:Apache License
public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy, int flags) throws SerializationException { if (cause == null) { throw new NullPointerException("cause cannot be null"); }/*from w w w. j a v a 2s . c o m*/ if (serializationPolicy == null) { throw new NullPointerException("serializationPolicy"); } if (serviceMethod != null && !RPCServletUtils.isExpectedException(serviceMethod, cause)) { throw new UnexpectedException("Service method '" + getSourceRepresentation(serviceMethod) + "' threw an unexpected exception: " + cause.toString(), cause); } return encodeResponse(cause.getClass(), cause, true, flags, serializationPolicy); }
From source file:com.foo.server.rpc230.CustomRPC.java
License:Apache License
public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, ServerSerializationStreamWriterSenasa streamWriter, int flags) throws SerializationException { if (cause == null) { throw new NullPointerException("cause cannot be null"); }// ww w . j av a 2s . com if (streamWriter == null) { throw new NullPointerException("streamWriter"); } if (serviceMethod != null && !RPCServletUtils.isExpectedException(serviceMethod, cause)) { throw new UnexpectedException("Service method '" + getSourceRepresentation(serviceMethod) + "' threw an unexpected exception: " + cause.toString(), cause); } return encodeResponse(cause.getClass(), cause, true, flags, streamWriter); }
From source file:de.itsvs.cwtrpc.controller.RemoteServiceControllerServlet.java
License:Apache License
protected String processInvocationException(HttpServletRequest servletRequest, Object service, RPCRequest rpcRequest, Throwable exception) throws ServletException, IOException, SerializationException, RuntimeException { final String responsePayload; if (RPCServletUtils.isExpectedException(rpcRequest.getMethod(), exception)) { if (log.isDebugEnabled()) { log.debug("Expected exception thrown when invoking method " + rpcRequest.getMethod() + " on service " + service.getClass().getName(), exception); }/*from w ww .ja v a2s . c om*/ responsePayload = processExpectedException(servletRequest, service, rpcRequest, exception); } else if (exception instanceof RuntimeException) { throw ((RuntimeException) exception); } else if (exception instanceof Error) { throw ((Error) exception); } else { throw new UnexpectedException("Unexpected checked exception " + "occured while invoking method " + rpcRequest.getMethod() + " on service " + service.getClass().getName(), exception); } return responsePayload; }