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
491c9780
Unverified
Commit
491c9780
authored
Mar 05, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
added user-defined exception 311
parent
6751d650
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
src/json.hpp
src/json.hpp
+2
-2
src/json.hpp.re2c
src/json.hpp.re2c
+2
-2
test/src/unit-modifiers.cpp
test/src/unit-modifiers.cpp
+4
-3
No files found.
src/json.hpp
View file @
491c9780
...
...
@@ -5607,7 +5607,7 @@ class basic_json
already-existing element if no insertion happened, and a bool
denoting whether the insertion took place.
@throw
std::domain_error
when called on a type other than JSON object or
@throw
type_error.311
when called on a type other than JSON object or
null; example: `"cannot use emplace() with number"`
@complexity Logarithmic in the size of the container, O(log(`size()`)).
...
...
@@ -5625,7 +5625,7 @@ class basic_json
// emplace only works for null objects or arrays
if
(
not
(
is_null
()
or
is_object
()))
{
JSON_THROW
(
std
::
domain_error
(
"cannot use emplace() with "
+
type_name
()));
JSON_THROW
(
type_error
(
311
,
"cannot use emplace() with "
+
type_name
()));
}
// transform null object into an object
...
...
src/json.hpp.re2c
View file @
491c9780
...
...
@@ -5607,7 +5607,7 @@ class basic_json
already-existing element if no insertion happened, and a bool
denoting whether the insertion took place.
@throw
std::domain_error
when called on a type other than JSON object or
@throw
type_error.311
when called on a type other than JSON object or
null; example: `"cannot use emplace() with number"`
@complexity Logarithmic in the size of the container, O(log(`size()`)).
...
...
@@ -5625,7 +5625,7 @@ class basic_json
// emplace only works for null objects or arrays
if (not(is_null() or is_object()))
{
JSON_THROW(
std::domain_error(
"cannot use emplace() with " + type_name()));
JSON_THROW(
type_error(311,
"cannot use emplace() with " + type_name()));
}
// transform null object into an object
...
...
test/src/unit-modifiers.cpp
View file @
491c9780
...
...
@@ -293,7 +293,7 @@ TEST_CASE("modifiers")
json
j
=
1
;
CHECK_THROWS_AS
(
j
.
emplace_back
(
"Hello"
),
json
::
type_error
);
CHECK_THROWS_WITH
(
j
.
emplace_back
(
"Hello"
),
"[json.exception.type_error.311] cannot use emplace_back() with number"
);
"[json.exception.type_error.311] cannot use emplace_back() with number"
);
}
}
...
...
@@ -351,8 +351,9 @@ TEST_CASE("modifiers")
SECTION
(
"other type"
)
{
json
j
=
1
;
CHECK_THROWS_AS
(
j
.
emplace
(
"foo"
,
"bar"
),
std
::
domain_error
);
CHECK_THROWS_WITH
(
j
.
emplace
(
"foo"
,
"bar"
),
"cannot use emplace() with number"
);
CHECK_THROWS_AS
(
j
.
emplace
(
"foo"
,
"bar"
),
json
::
type_error
);
CHECK_THROWS_WITH
(
j
.
emplace
(
"foo"
,
"bar"
),
"[json.exception.type_error.311] cannot use emplace() with number"
);
}
}
...
...
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