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
5cca44c1
Unverified
Commit
5cca44c1
authored
Mar 05, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
added user-defined exceptions 309
parent
70b2c3f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
32 deletions
+32
-32
src/json.hpp
src/json.hpp
+11
-11
src/json.hpp.re2c
src/json.hpp.re2c
+11
-11
test/src/unit-modifiers.cpp
test/src/unit-modifiers.cpp
+10
-10
No files found.
src/json.hpp
View file @
5cca44c1
...
...
@@ -5655,7 +5655,7 @@ class basic_json
@param[in] val element to insert
@return iterator pointing to the inserted @a val.
@throw
std::domain_error
if called on JSON values other than arrays;
@throw
type_error.309
if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5684,7 +5684,7 @@ class basic_json
return
result
;
}
JSON_THROW
(
std
::
domain_error
(
"cannot use insert() with "
+
type_name
()));
JSON_THROW
(
type_error
(
309
,
"cannot use insert() with "
+
type_name
()));
}
/*!
...
...
@@ -5708,8 +5708,8 @@ class basic_json
@return iterator pointing to the first element inserted, or @a pos if
`cnt==0`
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5737,7 +5737,7 @@ class basic_json
return
result
;
}
JSON_THROW
(
std
::
domain_error
(
"cannot use insert() with "
+
type_name
()));
JSON_THROW
(
type_error
(
309
,
"cannot use insert() with "
+
type_name
()));
}
/*!
...
...
@@ -5750,8 +5750,8 @@ class basic_json
@param[in] first begin of the range of elements to insert
@param[in] last end of the range of elements to insert
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
@throw invalid_iterator.210 if @a first and @a last do not belong to the
...
...
@@ -5775,7 +5775,7 @@ class basic_json
// insert only works for arrays
if
(
not
is_array
())
{
JSON_THROW
(
std
::
domain_error
(
"cannot use insert() with "
+
type_name
()));
JSON_THROW
(
type_error
(
309
,
"cannot use insert() with "
+
type_name
()));
}
// check if iterator pos fits to this JSON value
...
...
@@ -5813,8 +5813,8 @@ class basic_json
the end() iterator
@param[in] ilist initializer list to insert the values from
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5833,7 +5833,7 @@ class basic_json
// insert only works for arrays
if
(
not
is_array
())
{
JSON_THROW
(
std
::
domain_error
(
"cannot use insert() with "
+
type_name
()));
JSON_THROW
(
type_error
(
309
,
"cannot use insert() with "
+
type_name
()));
}
// check if iterator pos fits to this JSON value
...
...
src/json.hpp.re2c
View file @
5cca44c1
...
...
@@ -5655,7 +5655,7 @@ class basic_json
@param[in] val element to insert
@return iterator pointing to the inserted @a val.
@throw
std::domain_error
if called on JSON values other than arrays;
@throw
type_error.309
if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5684,7 +5684,7 @@ class basic_json
return result;
}
JSON_THROW(
std::domain_error(
"cannot use insert() with " + type_name()));
JSON_THROW(
type_error(309,
"cannot use insert() with " + type_name()));
}
/*!
...
...
@@ -5708,8 +5708,8 @@ class basic_json
@return iterator pointing to the first element inserted, or @a pos if
`cnt==0`
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5737,7 +5737,7 @@ class basic_json
return result;
}
JSON_THROW(
std::domain_error(
"cannot use insert() with " + type_name()));
JSON_THROW(
type_error(309,
"cannot use insert() with " + type_name()));
}
/*!
...
...
@@ -5750,8 +5750,8 @@ class basic_json
@param[in] first begin of the range of elements to insert
@param[in] last end of the range of elements to insert
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
@throw invalid_iterator.210 if @a first and @a last do not belong to the
...
...
@@ -5775,7 +5775,7 @@ class basic_json
// insert only works for arrays
if (not is_array())
{
JSON_THROW(
std::domain_error(
"cannot use insert() with " + type_name()));
JSON_THROW(
type_error(309,
"cannot use insert() with " + type_name()));
}
// check if iterator pos fits to this JSON value
...
...
@@ -5813,8 +5813,8 @@ class basic_json
the end() iterator
@param[in] ilist initializer list to insert the values from
@throw
std::domain_error if called on JSON values other than arrays;
example:
`"cannot use insert() with string"`
@throw
type_error.309 if called on JSON values other than arrays; example:
`"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"iterator does not fit current value"`
...
...
@@ -5833,7 +5833,7 @@ class basic_json
// insert only works for arrays
if (not is_array())
{
JSON_THROW(
std::domain_error(
"cannot use insert() with " + type_name()));
JSON_THROW(
type_error(309,
"cannot use insert() with " + type_name()));
}
// check if iterator pos fits to this JSON value
...
...
test/src/unit-modifiers.cpp
View file @
5cca44c1
...
...
@@ -686,20 +686,20 @@ TEST_CASE("modifiers")
// call insert on a non-array type
json
j_nonarray
=
3
;
json
j_yet_another_array
=
{
"first"
,
"second"
};
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
),
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_value
),
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
,
11
),
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
),
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_value
),
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
,
11
),
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
{
1
,
2
,
3
,
4
}),
std
::
domain
_error
);
j_yet_another_array
.
end
()),
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
{
1
,
2
,
3
,
4
}),
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
),
"cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_value
),
"cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
,
11
),
"cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
),
"
[json.exception.type_error.309]
cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_value
),
"
[json.exception.type_error.309]
cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
10
,
11
),
"
[json.exception.type_error.309]
cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
"cannot use insert() with number"
);
j_yet_another_array
.
end
()),
"
[json.exception.type_error.309]
cannot use insert() with number"
);
CHECK_THROWS_WITH
(
j_nonarray
.
insert
(
j_nonarray
.
end
(),
{
1
,
2
,
3
,
4
}),
"cannot use insert() with number"
);
"
[json.exception.type_error.309]
cannot use insert() 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