@Test public void testConvert() { final Throwable[] parameters = { new HerajException(""), new StatusRuntimeException(Status.UNAVAILABLE), new StatusRuntimeException(Status.INTERNAL), new UnsupportedOperationException(), }; final Class<?>[] expected = { HerajException.class, ConnectionException.class, HerajException.class, HerajException.class, }; final TransportExceptionConverter converter = new TransportExceptionConverter(); for (int i = 0; i < parameters.length; ++i) { final Throwable parameter = parameters[i]; final Class<?> expectedClass = expected[i]; final HerajException actual = converter.convert(parameter); assertEquals(actual.getClass(), expectedClass); } }
@Override public HerajException convert(final Throwable target) { logger.trace("Convert raw exception {}", target.toString()); if (target instanceof HerajException) { return (HerajException) target; } else if (target instanceof StatusRuntimeException) { return convertGrpcBasisException((StatusRuntimeException) target); } else { return new HerajException(target); } }
TransportExceptionConverter implements ExceptionConverter<HerajException> { @Override public HerajException convert(final Throwable target) { logger.trace("Convert raw exception {}", target.toString()); if (target instanceof HerajException) { return (HerajException) target; } else if (target instanceof StatusRuntimeException) { return convertGrpcBasisException((StatusRuntimeException) target); } else { return new HerajException(target); } } }
TransportExceptionConverter implements ExceptionConverter<HerajException> { @Override public HerajException convert(final Throwable target) { logger.trace("Convert raw exception {}", target.toString()); if (target instanceof HerajException) { return (HerajException) target; } else if (target instanceof StatusRuntimeException) { return convertGrpcBasisException((StatusRuntimeException) target); } else { return new HerajException(target); } }  }
TransportExceptionConverter implements ExceptionConverter<HerajException> { @Override public HerajException convert(final Throwable target) { logger.trace("Convert raw exception {}", target.toString()); if (target instanceof HerajException) { return (HerajException) target; } else if (target instanceof StatusRuntimeException) { return convertGrpcBasisException((StatusRuntimeException) target); } else { return new HerajException(target); } }  @Override HerajException convert(final Throwable target); }
TransportExceptionConverter implements ExceptionConverter<HerajException> { @Override public HerajException convert(final Throwable target) { logger.trace("Convert raw exception {}", target.toString()); if (target instanceof HerajException) { return (HerajException) target; } else if (target instanceof StatusRuntimeException) { return convertGrpcBasisException((StatusRuntimeException) target); } else { return new HerajException(target); } }  @Override HerajException convert(final Throwable target);  }