diff --git a/source/dub/internal/vibecompat/data/json.d b/source/dub/internal/vibecompat/data/json.d index 0faca18..268f9d6 100644 --- a/source/dub/internal/vibecompat/data/json.d +++ b/source/dub/internal/vibecompat/data/json.d @@ -30,6 +30,7 @@ import std.traits; version = JsonLineNumbers; +version = VibeJsonFieldNames; /******************************************************************************/ @@ -66,6 +67,7 @@ version (VibeJsonFieldNames) { uint m_magic = 0x1337f00d; // works around Appender bug (DMD BUG 10690/10859/11357) string m_name; + string m_fileName; } } @@ -404,7 +406,7 @@ else static if (is(T == float)) return cast(T)m_float; else static if (is(T == long)) return m_int; else static if (is(T == ulong)) return cast(ulong)m_int; - else static if (is(T : long)){ enforceJson(m_int <= T.max && m_int >= T.min, "Integer conversion out of bounds error"); return cast(T)m_int; } + else static if (is(T : long)){ enforceJson(m_int <= T.max && m_int >= T.min, "Integer conversion out of bounds error", m_fileName, line); return cast(T)m_int; } else static if (is(T == string)) return m_string; else static if (is(T == Json[])) return m_array; else static if (is(T == Json[string])) return m_object; @@ -841,8 +843,8 @@ } } - if (!op.length) throw new JSONException(format("Got %s, expected %s.", name, expected)); - else throw new JSONException(format("Got %s, expected %s for %s.", name, expected, op)); + enforceJson(op.length > 0, format("Got %s, expected %s.", name, expected), m_fileName, line); + enforceJson(false, format("Got %s, expected %s for %s.", name, expected, op), m_fileName, line); } /*invariant() @@ -873,7 +875,7 @@ skipWhitespace(range, line); version(JsonLineNumbers) { - import vibe.core.log; + import dub.internal.vibecompat.core.log; int curline = line ? *line : 0; } @@ -952,6 +954,7 @@ assert(ret.type != Json.Type.undefined); version(JsonLineNumbers) ret.line = curline; + ret.m_fileName = filename; return ret; }