DeviceOperationException extends Exception { public DeviceOperationException(String message, int errorCode) { super(message); this.errorCode = errorCode; } DeviceOperationException(String message, int errorCode);  DeviceOperationException(String message, int errorCode, Throwable cause); int getErrorCode();  }
@Test public void testDeviceOperationException() { DeviceOperationError error = new DeviceOperationError(DeviceOperationError.DEVICE_DENIED_THE_REQUEST); DeviceOperationException exception = new DeviceOperationException("CustomException", error.getReason(), null); try { throw exception; } catch (DeviceOperationException e) { Assert.assertEquals(DeviceOperationError.DEVICE_DENIED_THE_REQUEST, e.getErrorCode()); Assert.assertEquals("CustomException", e.getMessage()); } }