XfsException extends Exception { public static void throwFor(final long errorCode) throws XfsException { if (XfsError.SUCCESS.getValue() == errorCode) { return; } final int serviceOffset = Math.abs((int) errorCode / 100); for (AbstractXfsExceptionFactory factory : exceptionFactories) { if (factory.getServiceOffset() == serviceOffset) { factory.throwException(errorCode); } } throw new IllegalArgumentException("Unknown error code: " + errorCode); } protected  XfsException(final Enum<? extends XfsConstant> error); Enum<? extends XfsConstant> getError(); @Override String getMessage(); static void throwFor(final long errorCode); long getErrorCode();  }
@Test(expected = XfsServiceException.class) public void internalError() throws Exception { XfsException.throwFor(-15L); }
@Test(expected = XfsCancelledException.class) public void xfsCanceledException() throws Exception { XfsException.throwFor(-4); }
@Test(expected = IDCServiceException.class) public void idcServiceException() throws Exception { XfsException.throwFor(-200); }
@Test(expected = PINServiceException.class) public void pinServiceException() throws Exception { XfsException.throwFor(-411); }