public String getMessage() { String message = super.getMessage(); return (message != null) ? getExceptionLabel() + message : getExceptionLabel() + "(no message)"; } }
/** * Moves internal ResultSet cursor position down one row. Checks if the next row is * available. */ protected void checkNextRow() throws CayenneException { nextRow = false; try { if ((fetchLimit <= 0 || fetchedSoFar < fetchLimit) && resultSet.next()) { nextRow = true; fetchedSoFar++; } } catch (SQLException e) { throw new CayenneException("Error rewinding ResultSet", e); } }
/** * Creates new DistinctResultIterator wrapping another ResultIterator. * * @param wrappedIterator * @param defaultEntity an entity needed to build ObjectIds for distinct comparison. */ public DistinctResultIterator(ResultIterator wrappedIterator, DbEntity defaultEntity, boolean compareFullRows) throws CayenneException { if (wrappedIterator == null) { throw new CayenneException("Null wrapped iterator."); } if (defaultEntity == null) { throw new CayenneException("Null defaultEntity."); } this.wrappedIterator = wrappedIterator; this.defaultEntity = defaultEntity; this.fetchedIds = new HashSet(); this.compareFullRows = compareFullRows; checkNextRow(); }
/** * Returns message that includes Cayenne version label and the actual exception * message. */ public String getMessage() { String message = super.getMessage(); return (message != null) ? CayenneException.getExceptionLabel() + message : CayenneException.getExceptionLabel() + "(no message)"; } }
/** * @see org.apache.cayenne.access.ResultIterator#skipDataRow() */ public void skipDataRow() throws CayenneException { if (!hasNextRow()) { throw new CayenneException("An attempt to read uninitialized row or past the end of the iterator."); } try { checkNextRow(); } catch (SQLException sqex) { throw new CayenneException("Exception reading ResultSet.", sqex); } }
@Override public String getMessage() { String message = super.getMessage(); return (message != null) ? getExceptionLabel() + message : getExceptionLabel() + "(no message)"; } }
throw new CayenneException(deferredException);
/** * Returns message that includes Cayenne version label and the actual exception * message. */ @Override public String getMessage() { String message = super.getMessage(); return (message != null) ? CayenneException.getExceptionLabel() + message : CayenneException.getExceptionLabel() + "(no message)"; } }
public ResultIterator getResultIterator() throws CayenneException { if (super.hasExceptions()) { StringWriter str = new StringWriter(); PrintWriter out = new PrintWriter(str); super.printExceptions(out); try { out.close(); str.close(); } catch (IOException ioex) { // this should never happen } throw new CayenneException( "Error getting ResultIterator: " + str.getBuffer()); } return resultIterator; }
@Override public String getMessage() { String message = super.getMessage(); return (message != null) ? getExceptionLabel() + message : getExceptionLabel() + "(no message)"; } }
public Map nextDataRow() throws CayenneException { if (!hasNextRow()) { throw new CayenneException( "An attempt to read uninitialized row or past the end of the iterator."); } Map row = nextDataRow; checkNextRow(); return row; }
/** * Returns message that includes Cayenne version label and the actual exception * message. */ @Override public String getMessage() { String message = super.getMessage(); return (message != null) ? CayenneException.getExceptionLabel() + message : CayenneException.getExceptionLabel() + "(no message)"; } }
/** * Returns the next result row as a Map. */ public Map nextDataRow() throws CayenneException { if (!hasNextRow()) { throw new CayenneException("An attempt to read uninitialized row or past the end of the iterator."); } try { // read Map row = readDataRow(); // rewind checkNextRow(); return row; } catch (SQLException sqex) { throw new CayenneException("Exception reading ResultSet.", sqex); } }
@Test public void testException() { Response response = target("/g1").request().get(); String cayenneVersion = CayenneException.getExceptionLabel(); String expected = String .format("{\"success\":false,\"message\":\"CayenneRuntimeException %s_something_w_cayenne_\"}", cayenneVersion); onResponse(response) .statusEquals(Response.Status.INTERNAL_SERVER_ERROR) .bodyEquals(expected); }
/** * Returns a map of ObjectId values from the next result row. * Primary key columns are determined from the provided DbEntity. * * @since 1.1 */ public Map nextObjectId(DbEntity entity) throws CayenneException { if (!hasNextRow()) { throw new CayenneException("An attempt to read uninitialized row or past the end of the iterator."); } try { // read Map row = readIdRow(entity); // rewind checkNextRow(); return row; } catch (SQLException sqex) { throw new CayenneException("Exception reading ResultSet.", sqex); } } }
void checkNextRow() throws CayenneException { if (readingIds) { throw new CayenneException( "Can't go back from reading ObjectIds to reading rows."); } if (this.compareFullRows) { checkNextUniqueRow(); } else { checkNextRowWithUniqueId(); } }
public void skipDataRow() throws CayenneException { if (!hasNextRow()) { throw new CayenneException( "An attempt to read uninitialized row or past the end of the iterator."); } checkNextRow(); }
void checkNextId(DbEntity entity) throws CayenneException { if (entity == null) { throw new CayenneException("Null DbEntity, can't create id."); } this.readingIds = true; this.nextDataRow = null; while (wrappedIterator.hasNextRow()) { Map next = wrappedIterator.nextObjectId(entity); // if we are reading ids, we ignore "compareFullRows" setting if (fetchedIds.add(next)) { this.nextDataRow = next; break; } } } }
throw new CayenneException("Can't port data, source node is null."); throw new CayenneException("Can't port data, destination node is null."); throw new CayenneException( "Can't port data, source and target nodes are the same.");
throw new CayenneException("Error closing ResultIterator: " + buf);