All Downloads are FREE. Search and download functionalities are using the official Maven repository.

colesico.framework.rpc.clientapi.handler.BasicRpcErrorHandler Maven / Gradle / Ivy

The newest version!
package colesico.framework.rpc.clientapi.handler;

import colesico.framework.rpc.RpcError;
import colesico.framework.rpc.RpcException;
import colesico.framework.rpc.clientapi.RpcErrorHandler;

import javax.inject.Singleton;

@Singleton
public class BasicRpcErrorHandler implements RpcErrorHandler {

    @Override
    public RuntimeException createException(RpcError error) {
        try {
            Class exClass = Class.forName(error.getExceptionType());
            RuntimeException ex = (RuntimeException) exClass
                    .getDeclaredConstructor(String.class)
                    .newInstance(error.getMessage());
            return ex;
        } catch (Exception e) {
            return new RpcException(error.getMessage());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy