Skip to content

Commit

Permalink
Give the user a meaningful exception message when here tries to write…
Browse files Browse the repository at this point in the history
… a Decimal.
  • Loading branch information
lanwin committed Jun 2, 2010
1 parent 41b19cb commit e6503e1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/MongoDB/Bson/BsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ protected BsonType TranslateToBsonType(object obj)
if(_descriptor.IsObject(obj))
return BsonType.Obj;

if(type == typeof(Decimal))
throw new ArgumentOutOfRangeException("Decimal is not supported in the BSON spec. So it is also not supported in MongoDB. " +
"You could convert it to double or store it as Binary instead.");

throw new ArgumentOutOfRangeException(String.Format("Type: {0} not recognized", type.FullName));
}
}
Expand Down

0 comments on commit e6503e1

Please sign in to comment.