/** * Throws a {@code CommandFailureException} if the command failed. Otherwise, returns normally. * * @throws MongoException with the exception from the failed command * @see #ok() */ public void throwOnError() { if (!ok()) { throw createException(); } }
/** * Utility method to create an exception from a failed command. * * @return The mongo exception, or null if the command was successful. */ @Nullable public MongoException getException() { if (!ok()) { return createException(); } return null; }
/** * Throws a {@code CommandFailureException} if the command failed. Otherwise, returns normally. * * @throws MongoException with the exception from the failed command * @see #ok() */ public void throwOnError() { if (!ok()) { throw createException(); } }
/** * Utility method to create an exception from a failed command. * * @return The mongo exception, or null if the command was successful. */ @Nullable public MongoException getException() { if (!ok()) { return createException(); } return null; }