org.mongodb.MongoException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongoFS Show documentation
Show all versions of mongoFS Show documentation
An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports.
Compressed file storage, zip files, temporary files
package org.mongodb;
import org.bson.BSONObject;
/**
* A general exception raised in Mongo
*
* @author antoine
*/
public class MongoException extends RuntimeException {
private static final long serialVersionUID = -4415279469780082174L;
/**
* @param msg
* the message
*/
public MongoException(final String msg) {
super(msg);
this.code = -3;
}
/**
*
* @param code
* the error code
* @param msg
* the message
*/
public MongoException(final int code, final String msg) {
super(msg);
this.code = code;
}
/**
*
* @param msg
* the message
* @param t
* the throwable cause
*/
public MongoException(final String msg, final Throwable t) {
super(msg, t);
this.code = -4;
}
/**
*
* @param code
* the error code
* @param msg
* the message
* @param t
* the throwable cause
*/
public MongoException(final int code, final String msg, final Throwable t) {
super(msg, t);
this.code = code;
}
/**
* Creates a MongoException from a BSON object representing an error
*
* @param o
*/
public MongoException(final BSONObject o) {
this(ServerError.getCode(o), ServerError.getMsg(o, "UNKNOWN"));
}
static MongoException parse(final BSONObject o) {
String s = ServerError.getMsg(o, null);
if (s == null) {
return null;
}
return new MongoException(ServerError.getCode(o), s);
}
/**
* Gets the exception code
*
* @return code
*/
public int getCode() {
return code;
}
private final int code;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy