Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
068c7acd
Unverified
Commit
068c7acd
authored
Mar 05, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
added user-defined exceptions 301
parent
0c40c8e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
json.hpp
src/json.hpp
+4
-4
json.hpp.re2c
src/json.hpp.re2c
+4
-4
unit-constructor1.cpp
test/src/unit-constructor1.cpp
+2
-2
No files found.
src/json.hpp
View file @
068c7acd
...
...
@@ -2223,8 +2223,8 @@ class basic_json
value_t::array and @ref value_t::object are valid); when @a type_deduction
is set to `true`, this parameter has no effect
@throw
std::domain_error if @a type_deduction is `false`, @a manual_type
is
`value_t::object`, but @a init contains an element which is not a pair
@throw
type_error.301 if @a type_deduction is `false`, @a manual_type is
`value_t::object`, but @a init contains an element which is not a pair
whose first element is a string; example: `"cannot create object from
initializer list"`
...
...
@@ -2264,7 +2264,7 @@ class basic_json
// if object is wanted but impossible, throw an exception
if
(
manual_type
==
value_t
::
object
and
not
is_an_object
)
{
JSON_THROW
(
std
::
domain_error
(
"cannot create object from initializer list"
));
JSON_THROW
(
type_error
(
301
,
"cannot create object from initializer list"
));
}
}
...
...
@@ -2347,7 +2347,7 @@ class basic_json
@return JSON object value
@throw
std::domain_error
if @a init is not a pair whose first elements are
@throw
type_error.301
if @a init is not a pair whose first elements are
strings; thrown by
@ref basic_json(std::initializer_list<basic_json>, bool, value_t)
...
...
src/json.hpp.re2c
View file @
068c7acd
...
...
@@ -2223,8 +2223,8 @@ class basic_json
value_t::array and @ref value_t::object are valid); when @a type_deduction
is set to `true`, this parameter has no effect
@throw
std::domain_error if @a type_deduction is `false`, @a manual_type
is
`value_t::object`, but @a init contains an element which is not a pair
@throw
type_error.301 if @a type_deduction is `false`, @a manual_type is
`value_t::object`, but @a init contains an element which is not a pair
whose first element is a string; example: `"cannot create object from
initializer list"`
...
...
@@ -2264,7 +2264,7 @@ class basic_json
// if object is wanted but impossible, throw an exception
if (manual_type == value_t::object and not is_an_object)
{
JSON_THROW(
std::domain_error(
"cannot create object from initializer list"));
JSON_THROW(
type_error(301,
"cannot create object from initializer list"));
}
}
...
...
@@ -2347,7 +2347,7 @@ class basic_json
@return JSON object value
@throw
std::domain_error
if @a init is not a pair whose first elements are
@throw
type_error.301
if @a init is not a pair whose first elements are
strings; thrown by
@ref basic_json(std::initializer_list<basic_json>, bool, value_t)
...
...
test/src/unit-constructor1.cpp
View file @
068c7acd
...
...
@@ -943,9 +943,9 @@ TEST_CASE("constructors")
SECTION
(
"object with error"
)
{
CHECK_THROWS_AS
(
json
::
object
({
{
"one"
,
1
},
{
"two"
,
1u
},
{
"three"
,
2.2
},
{
"four"
,
false
},
13
}),
std
::
logic
_error
);
json
::
type
_error
);
CHECK_THROWS_WITH
(
json
::
object
({
{
"one"
,
1
},
{
"two"
,
1u
},
{
"three"
,
2.2
},
{
"four"
,
false
},
13
}),
"cannot create object from initializer list"
);
"
[json.exception.type_error.301]
cannot create object from initializer list"
);
}
SECTION
(
"empty array"
)
...
...
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