@Override public String toString() { return getClass().getName() + "(" + className + "): " + getMessage(); } }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
consoleMessage("Unexpected error:" + eCreate.getMessage()); consoleMessage("Unexpected error:" + eAppend.getMessage());
consoleMessage("Unexpected error:" + eCreate.getMessage()); consoleMessage("Unexpected error:" + eAppend.getMessage());
if (e.getMessage().indexOf(NotServingRegionException.class.getName()) >= 0) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to get compaction state of " + loc.getRegion() + ": " +
if (e.getMessage().indexOf(NotServingRegionException.class.getName()) >= 0) { if (LOG.isDebugEnabled()) { LOG.debug("Trying to get compaction state of " + loc.getRegion() + ": " +
@Override public String toString() { return getClass().getName() + "(" + className + "): " + getMessage(); } }
@Override public String toString() { return getClass().getName() + "(" + className + "): " + getMessage(); } }
@Override public String toString() { return getClass().getName() + "(" + className + "): " + getMessage(); } }
@Override public String toString() { return getClass().getName() + "(" + className + "): " + getMessage(); } }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); IOException ex = cn.newInstance(this.getMessage()); ex.initCause(this); return ex; }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); String firstLine = this.getMessage(); int eol = firstLine.indexOf('\n'); if (eol>=0) { firstLine = firstLine.substring(0, eol); } IOException ex = cn.newInstance(firstLine); ex.initCause(this); return ex; }
private IOException instantiateException(Class<? extends IOException> cls) throws Exception { Constructor<? extends IOException> cn = cls.getConstructor(String.class); cn.setAccessible(true); String firstLine = this.getMessage(); int eol = firstLine.indexOf('\n'); if (eol>=0) { firstLine = firstLine.substring(0, eol); } IOException ex = cn.newInstance(firstLine); ex.initCause(this); return ex; }
private static <T extends Throwable> T instantiateException( Class<? extends T> cls, RemoteException re) throws RemoteException { try { Constructor<? extends T> cn = cls.getConstructor(String.class); cn.setAccessible(true); T ex = cn.newInstance(re.getMessage()); ex.initCause(re); return ex; // RemoteException contains useful information as against the // java.lang.reflect exceptions. } catch (NoSuchMethodException e) { throw re; } catch (IllegalArgumentException e) { throw re; } catch (SecurityException e) { throw re; } catch (InstantiationException e) { throw re; } catch (IllegalAccessException e) { throw re; } catch (InvocationTargetException e) { throw re; } }
private void getBlocksWithException(NamenodeProtocol namenode, DatanodeInfo datanode, long size) throws IOException { boolean getException = false; try { namenode.getBlocks(new DatanodeInfo(), 2); } catch(RemoteException e) { getException = true; assertTrue(e.getMessage().contains("IllegalArgumentException")); } assertTrue(getException); }
@Test (timeout=5000) public void testProtoBufRandomException() throws Exception { TestRpcService client = getClient(); EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build(); try { client.error2(null, emptyRequest); } catch (ServiceException se) { Assert.assertTrue(se.getCause() instanceof RemoteException); RemoteException re = (RemoteException) se.getCause(); Assert.assertTrue(re.getClassName().equals( URISyntaxException.class.getName())); Assert.assertTrue(re.getMessage().contains("testException")); Assert.assertTrue( re.getErrorCode().equals(RpcErrorCodeProto.ERROR_APPLICATION)); } }
@Test (timeout=5000) public void testProtoBufRandomException() throws Exception { TestRpcService client = getClient(); EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build(); try { client.error2(null, emptyRequest); } catch (ServiceException se) { Assert.assertTrue(se.getCause() instanceof RemoteException); RemoteException re = (RemoteException) se.getCause(); Assert.assertTrue(re.getClassName().equals( URISyntaxException.class.getName())); Assert.assertTrue(re.getMessage().contains("testException")); Assert.assertTrue( re.getErrorCode().equals(RpcErrorCodeProto.ERROR_APPLICATION)); } }