summaryrefslogtreecommitdiff
path: root/jstests/error1.js
blob: 9fd7acea00d684156fba878d16ae23245fd60152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

// test 1
db.$cmd.findOne({reseterror:1});
assert( db.$cmd.findOne({getlasterror:1}).err == null );
assert( db.$cmd.findOne({getpreverror:1}).err == null );

db.resetError();
assert( db.getLastError() == null );
assert( db.getPrevError().err == null , "preverror 1" );

// test 2

db.$cmd.findOne({forceerror:1});
assert( db.$cmd.findOne({getlasterror:1}).err != null );
assert( db.$cmd.findOne({getpreverror:1}).err != null );


assert( db.getLastError() != null );
assert( db.getPrevError().err != null , "preverror 2" );


db.foo.findOne();
assert( db.$cmd.findOne({getlasterror:1}).err == null );
assert( db.$cmd.findOne({getpreverror:1}).err != null );
assert( db.$cmd.findOne({getpreverror:1}).nPrev == 2 );

db.resetError();
db.forceError();
db.foo.findOne();
assert( db.getLastError() == null , "getLastError 5" );
assert( db.getPrevError().err != null , "preverror 3" );

// test 3
db.$cmd.findOne({reseterror:1});
assert( db.$cmd.findOne({getpreverror:1}).err == null );