static Name fromProtocolId(int id) { Name name = nameToIds[id]; if (name == null) throw new DriverInternalError("Unknown data type protocol id: " + id); return name; }
@Override public DriverInternalError copy() { return new DriverInternalError(getMessage(), this); } }
List<String> parseTypeParameters() { List<String> list = new ArrayList<String>(); if (isEOS()) return list; skipBlankAndComma(); if (str.charAt(idx) != '<') throw new IllegalStateException(); ++idx; // skipping '<' while (skipBlankAndComma()) { if (str.charAt(idx) == '>') { ++idx; return list; } try { String name = parseTypeName(); String args = readRawTypeParameters(); list.add(name + args); } catch (DriverInternalError e) { DriverInternalError ex = new DriverInternalError( String.format("Exception while parsing '%s' around char %d", str, idx)); ex.initCause(e); throw ex; } } throw new DriverInternalError( String.format( "Syntax error parsing '%s' at char %d: unexpected end of string", str, idx)); }
/** Tests DriverInternalError. Tests basic message, rethrow, and copy abilities. */ @Test(groups = "unit") public void driverInternalError() throws Exception { String errorMessage = "Test Message"; try { throw new DriverInternalError(errorMessage); } catch (DriverInternalError e1) { try { throw new DriverInternalError(e1); } catch (DriverInternalError e2) { assertTrue(e2.getMessage().contains(errorMessage)); DriverInternalError copy = (DriverInternalError) e2.copy(); assertEquals(copy.getMessage(), e2.getMessage()); } } }
/** Tests DriverInternalError. Tests basic message, rethrow, and copy abilities. */ @Test(groups = "unit") public void driverInternalError() throws Exception { String errorMessage = "Test Message"; try { throw new DriverInternalError(errorMessage); } catch (DriverInternalError e1) { try { throw new DriverInternalError(e1); } catch (DriverInternalError e2) { assertTrue(e2.getMessage().contains(errorMessage)); DriverInternalError copy = (DriverInternalError) e2.copy(); assertEquals(copy.getMessage(), e2.getMessage()); } } }
DriverInternalError unsupported() { return new DriverInternalError("Unsupported protocol version " + this); }
public List<String> getTypeParameters() { List<String> list = new ArrayList<String>(); if (isEOS()) return list; if (str.charAt(idx) != '(') throw new IllegalStateException(); ++idx; // skipping '(' while (skipBlankAndComma()) { if (str.charAt(idx) == ')') { ++idx; return list; } try { list.add(readOne()); } catch (DriverInternalError e) { DriverInternalError ex = new DriverInternalError(String.format("Exception while parsing '%s' around char %d", str, idx)); ex.initCause(e); throw ex; } } throw new DriverInternalError(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx)); }
@Override public DriverInternalError copy() { return new DriverInternalError(getMessage(), this); } }
assertThat(die.getCause()).isInstanceOf(IllegalStateException.class);
private Message.ProtocolEncoder messageEncoderFor(ProtocolVersion version) { switch (version) { case V1: return messageEncoderV1; case V2: return messageEncoderV2; case V3: return messageEncoderV3; case V4: return messageEncoderV4; case V5: return messageEncoderV5; default: throw new DriverInternalError("Unsupported protocol version " + protocolVersion); } } }
public List<String> getTypeParameters() { List<String> list = new ArrayList<String>(); if (isEOS()) return list; if (str.charAt(idx) != '(') throw new IllegalStateException(); ++idx; // skipping '(' while (skipBlankAndComma()) { if (str.charAt(idx) == ')') { ++idx; return list; } try { list.add(readOne()); } catch (DriverInternalError e) { DriverInternalError ex = new DriverInternalError(String.format("Exception while parsing '%s' around char %d", str, idx)); ex.initCause(e); throw ex; } } throw new DriverInternalError(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx)); }
@Override public DriverInternalError copy() { return new DriverInternalError(getMessage(), this); } }
static Kind fromId(int id) { Kind k = ids[id]; if (k == null) throw new DriverInternalError(String.format("Unknown kind id %d in RESULT message", id)); return k; } }
public List<String> getTypeParameters() { List<String> list = new ArrayList<String>(); if (isEOS()) return list; if (str.charAt(idx) != '(') throw new IllegalStateException(); ++idx; // skipping '(' while (skipBlankAndComma()) { if (str.charAt(idx) == ')') { ++idx; return list; } try { list.add(readOne()); } catch (DriverInternalError e) { DriverInternalError ex = new DriverInternalError(String.format("Exception while parsing '%s' around char %d", str, idx)); ex.initCause(e); throw ex; } } throw new DriverInternalError(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx)); }
@Override public DriverException copy() { return new DriverInternalError(getMessage(), this); } }
static Type fromOpcode(int opcode) { if (opcode < 0 || opcode >= opcodeIdx.length) throw new DriverInternalError(String.format("Unknown response opcode %d", opcode)); Type t = opcodeIdx[opcode]; if (t == null) throw new DriverInternalError(String.format("Unknown response opcode %d", opcode)); return t; } }
List<String> getTypeParameters() { if (isEOS()) { return Collections.emptyList(); } List<String> list = new ArrayList<String>(); if (str.charAt(idx) != '(') { throw new IllegalStateException(); } ++idx; // skipping '(' while (skipBlankAndComma()) { if (str.charAt(idx) == ')') { ++idx; return list; } try { list.add(readOne()); } catch (DriverInternalError e) { DriverInternalError ex = new DriverInternalError(String.format("Exception while parsing '%s' around char %d", str, idx)); ex.initCause(e); throw ex; } } return list; }
@Override public DriverInternalError copy() { return new DriverInternalError(getMessage(), this); } }