summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-03-16 22:13:19 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-03-16 22:13:19 +0000
commit3b2787badaf54be2b6b5353dbd1b0af5ccff1db4 (patch)
tree9afc847e7a5bcc21ddeb8fcdb99a1b64da8668e9 /src
parentd475be6b00e0b57d704c4cf36e657a3dbe8c3c78 (diff)
sensible error message if doc._rev is null or a number
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@755023 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_doc.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/couchdb/couch_doc.erl b/src/couchdb/couch_doc.erl
index 3c4fd98c..03cc8906 100644
--- a/src/couchdb/couch_doc.erl
+++ b/src/couchdb/couch_doc.erl
@@ -128,12 +128,14 @@ from_json_obj(_Other) ->
parse_rev(Rev) when is_binary(Rev) ->
parse_rev(?b2l(Rev));
-parse_rev(Rev) ->
+parse_rev(Rev) when is_list(Rev) ->
SplitRev = lists:splitwith(fun($-) -> false; (_) -> true end, Rev),
case SplitRev of
{Pos, [$- | RevId]} -> {list_to_integer(Pos), ?l2b(RevId)};
_Else -> throw({bad_request, <<"Invalid rev format">>})
- end.
+ end;
+parse_rev(_BadRev) ->
+ throw({bad_request, <<"Invalid rev format">>}).
parse_revs([]) ->
[];