From 7b68091f386368641ed10e1a1ac586fc6365f1c1 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Wed, 6 May 2020 08:16:00 -0600 Subject: [PATCH] Throw a more informative error on invalid numbers. Fixes #57. --- src/JSON3.jl | 2 +- src/read.jl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/JSON3.jl b/src/JSON3.jl index 4b5d297..3150500 100644 --- a/src/JSON3.jl +++ b/src/JSON3.jl @@ -26,7 +26,7 @@ invalid JSON at byte position $pos while parsing type $T: $error $(String(buf[max(1, pos-25):min(end, pos+25)])) """)) -@enum Error UnexpectedEOF ExpectedOpeningObjectChar ExpectedOpeningQuoteChar ExpectedOpeningArrayChar ExpectedClosingArrayChar ExpectedComma ExpectedSemiColon InvalidChar +@enum Error UnexpectedEOF ExpectedOpeningObjectChar ExpectedOpeningQuoteChar ExpectedOpeningArrayChar ExpectedClosingArrayChar ExpectedComma ExpectedSemiColon InvalidChar InvalidNumber # AbstractDict interface function Base.length(obj::Object) diff --git a/src/read.jl b/src/read.jl index d9d8f24..3141fd8 100644 --- a/src/read.jl +++ b/src/read.jl @@ -66,6 +66,7 @@ function read!(buf, pos, len, b, tape, tapeidx, ::Type{Any}, checkint=true) end return floatpos, tapeidx + 2 end + invalid(InvalidNumber, buf, pos, Float64) end @label invalid invalid(InvalidChar, buf, pos, Any)