Skip to content

Commit 5cd1218

Browse files
author
Ryan
committed
initial load - JAVA-265
1 parent cb30235 commit 5cd1218

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

src/main/org/bson/BSONException.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright (C) 2011, 10gen Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.bson;
18+
19+
/**
20+
* A general runtime exception raised in BSON processing.
21+
*/
22+
public class BSONException extends RuntimeException {
23+
24+
private static final long serialVersionUID = -4415279469780082174L;
25+
26+
/**
27+
* @param msg The error message.
28+
*/
29+
public BSONException( final String msg ) {
30+
super( msg );
31+
}
32+
33+
/**
34+
* @param errorCode The error code.
35+
* @param msg The error message.
36+
*/
37+
public BSONException( final String errorCode, final String msg ) {
38+
super( msg );
39+
_errorCode = errorCode;
40+
}
41+
42+
/**
43+
* @param msg The error message.
44+
* @param t The throwable cause.
45+
*/
46+
public BSONException( final String msg , final Throwable t ) {
47+
super( msg, t );
48+
}
49+
50+
/**
51+
* @param errorCode The error code.
52+
* @param msg The error message.
53+
* @param t The throwable cause.
54+
*/
55+
public BSONException( final String errorCode, final String msg, final Throwable t ) {
56+
super( msg, t );
57+
_errorCode = errorCode;
58+
}
59+
60+
/**
61+
* Returns the error code.
62+
* @return The error code.
63+
*/
64+
public String getErrorCode() { return _errorCode; }
65+
66+
/**
67+
* Returns true if the error code is set (i.e., not null).
68+
*/
69+
public boolean hasErrorCode() {
70+
return (_errorCode != null) ? true : false;
71+
}
72+
73+
private String _errorCode = null;
74+
}
75+

0 commit comments

Comments
 (0)