All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mongodb.ServerError Maven / Gradle / Ivy

Go to download

An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports. Compressed file storage, zip files, temporary files

There is a newer version: 0.10.0
Show newest version
package org.mongodb;

import org.bson.BSONObject;

public final class ServerError {

    static String getMsg(final BSONObject o, final String def) {
        Object e = o.get("$err");
        if (e == null) {
            e = o.get("err");
        }
        if (e == null) {
            e = o.get("errmsg");
        }
        if (e == null) {
            return def;
        }
        return e.toString();
    }

    static int getCode(final BSONObject o) {
        Object c = o.get("code");
        if (c == null) {
            c = o.get("$code");
        }
        if (c == null) {
            c = o.get("assertionCode");
        }
        if (c == null) {
            return -5;
        }
        return ((Number) c).intValue();
    }

    private ServerError() {
        // empty
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy