Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
7fa3b886
Unverified
Commit
7fa3b886
authored
Sep 18, 2018
by
Niels Lohmann
Committed by
GitHub
Sep 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1221 from rivertam/better-error-305
Better error 305
parents
186c747a
8f07ab63
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
51 deletions
+51
-51
include/nlohmann/json.hpp
include/nlohmann/json.hpp
+6
-6
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+6
-6
test/src/unit-element_access1.cpp
test/src/unit-element_access1.cpp
+13
-13
test/src/unit-element_access2.cpp
test/src/unit-element_access2.cpp
+26
-26
No files found.
include/nlohmann/json.hpp
View file @
7fa3b886
...
...
@@ -3097,7 +3097,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a numeric argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -3127,7 +3127,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a numeric argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -3173,7 +3173,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -3215,7 +3215,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -3262,7 +3262,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -3305,7 +3305,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
single_include/nlohmann/json.hpp
View file @
7fa3b886
...
...
@@ -14170,7 +14170,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a numeric argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -14200,7 +14200,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a numeric argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -14246,7 +14246,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -14288,7 +14288,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -14335,7 +14335,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
@@ -14378,7 +14378,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with "
+
std
::
string
(
type_name
())));
JSON_THROW
(
type_error
::
create
(
305
,
"cannot use operator[] with
a string argument with
"
+
std
::
string
(
type_name
())));
}
/*!
...
...
test/src/unit-element_access1.cpp
View file @
7fa3b886
...
...
@@ -195,7 +195,7 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_NOTHROW
(
j_nonarray
[
0
]);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with null"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
null"
);
}
SECTION
(
"implicit transformation to properly filled array"
)
...
...
@@ -212,8 +212,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
boolean"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
boolean"
);
}
SECTION
(
"string"
)
...
...
@@ -222,8 +222,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
string"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
string"
);
}
SECTION
(
"object"
)
...
...
@@ -232,8 +232,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with object"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with object"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
object"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
object"
);
}
SECTION
(
"number (integer)"
)
...
...
@@ -242,8 +242,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
}
SECTION
(
"number (unsigned)"
)
...
...
@@ -252,8 +252,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
}
SECTION
(
"number (floating-point)"
)
...
...
@@ -262,8 +262,8 @@ TEST_CASE("element access 1")
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type_error
&
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type_error
&
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"[json.exception.type_error.305] cannot use operator[] with
a numeric argument with
number"
);
}
}
}
...
...
test/src/unit-element_access2.cpp
View file @
7fa3b886
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment