/** * Converts any passed exception to IGFS exception. * * @param err Initial exception. * @return Converted IGFS exception. */ public static IgfsException toIgfsException(Throwable err) { IgfsException err0 = err instanceof IgfsException ? (IgfsException)err : null; IgfsException igfsErr = X.cause(err, IgfsException.class); while (igfsErr != null && igfsErr != err0) { err0 = igfsErr; igfsErr = X.cause(err, IgfsException.class); } // If initial exception is already IGFS exception and no inner stuff exists, just return it unchanged. if (err0 != err) { if (err0 != null) // Dealing with a kind of IGFS error, wrap it once again, preserving message and root cause. err0 = newIgfsException(err0.getClass(), err0.getMessage(), err0); else { if (err instanceof ClusterTopologyServerNotFoundException) err0 = new IgfsException("Cache server nodes not found.", err); else // Unknown error nature. err0 = new IgfsException("Generic IGFS error occurred.", err); } } return err0; }
/** * Converts any passed exception to IGFS exception. * * @param err Initial exception. * @return Converted IGFS exception. */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored") public static IgfsException toIgfsException(Throwable err) { IgfsException err0 = err instanceof IgfsException ? (IgfsException)err : null; IgfsException igfsErr = X.cause(err, IgfsException.class); while (igfsErr != null && igfsErr != err0) { err0 = igfsErr; igfsErr = X.cause(err, IgfsException.class); } // If initial exception is already IGFS exception and no inner stuff exists, just return it unchanged. if (err0 != err) { if (err0 != null) // Dealing with a kind of IGFS error, wrap it once again, preserving message and root cause. err0 = newIgfsException(err0.getClass(), err0.getMessage(), err0); else { if (err instanceof ClusterTopologyServerNotFoundException) err0 = new IgfsException("Cache server nodes not found.", err); else // Unknown error nature. err0 = new IgfsException("Generic IGFS error occurred.", err); } } return err0; }