protected DatastoreException newInvalidRequest(String msg, Object... params) { return DatastoreException.throwInvalidRequest(String.format(msg, params)); }
/** * Returns the {@link Value} for the given property {@code name}. * * @throws DatastoreException if no such property */ public <V extends Value<?>> V getValue(String name) { @SuppressWarnings("unchecked") V property = (V) properties.get(name); if (property == null) { throw DatastoreException.throwInvalidRequest("No such property %s", name); } return property; }
throw DatastoreException.throwInvalidRequest( "Duplicate entity with the key %s", entity.getKey());
@Test public void testThrowInvalidRequest() throws Exception { try { DatastoreException.throwInvalidRequest("message %s %d", "a", 1); fail("Exception expected"); } catch (DatastoreException ex) { assertEquals("FAILED_PRECONDITION", ex.getReason()); assertEquals("message a 1", ex.getMessage()); } } }
protected DatastoreException newInvalidRequest(String msg, Object... params) { return DatastoreException.throwInvalidRequest(String.format(msg, params)); }
/** * Returns the {@link Value} for the given property {@code name}. * * @throws DatastoreException if no such property */ public <V extends Value<?>> V getValue(String name) { @SuppressWarnings("unchecked") V property = (V) properties.get(name); if (property == null) { throw DatastoreException.throwInvalidRequest("No such property %s", name); } return property; }
throw DatastoreException.throwInvalidRequest( "Duplicate entity with the key %s", entity.getKey());