Skip to content

Commit 1a76ea3

Browse files
committed
refactor error API: update swig file
1 parent 7cc0682 commit 1a76ea3

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

api/ryml.i

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ using csubstr = c4::csubstr;
122122
%exception {
123123
try {
124124
$action
125-
} catch(std::exception &e) {
125+
} catch(std::exception const& e) {
126126
SWIG_exception(SWIG_RuntimeError, e.what());
127127
} catch(...) {
128128
SWIG_exception(SWIG_UnknownError, "unknown error");
@@ -150,7 +150,7 @@ char * emit_yaml_malloc(c4::yml::Tree const& t, size_t id)
150150
c4::substr ret = c4::yml::emit_yaml(t, id, buf, /*error_on_excess*/false);
151151
if(ret.str == nullptr && ret.len > 0)
152152
{
153-
// Use new[] to parse with delete[] in SWIG.
153+
// Use new[]+delete[] in SWIG.
154154
char * alloc = new char[ret.len + 1]; // we'll return a c-string and not a csubstr
155155
c4::substr alloced_buf(alloc, ret.len);
156156
ret = c4::yml::emit_yaml(t, id, alloced_buf, /*error_on_excess*/true);
@@ -165,7 +165,7 @@ char * emit_json_malloc(c4::yml::Tree const& t, size_t id)
165165
c4::substr ret = c4::yml::emit_json(t, id, buf, /*error_on_excess*/false);
166166
if(ret.str == nullptr && ret.len > 0)
167167
{
168-
// Use new[] to parse with delete[] in SWIG.
168+
// Use new[]+delete[] in SWIG.
169169
char * alloc = new char[ret.len + 1]; // we'll return a c-string and not a csubstr
170170
c4::substr alloced_buf(alloc, ret.len);
171171
ret = c4::yml::emit_json(t, id, alloced_buf, /*error_on_excess*/true);
@@ -292,7 +292,8 @@ def parse(buf, **kwargs):
292292
return parse_in_arena(tree, id)
293293

294294
def parse_in_arena(buf, tree=None):
295-
"""parse immutable YAML in the trees arena. Copy the YAML into a buffer
295+
"""
296+
parse immutable YAML in the trees arena. Copy the YAML into a buffer
296297
in the C++ tree's arena, then parse the YAML from the trees arena.
297298
298299
:param buf:
@@ -307,7 +308,8 @@ def parse_in_arena(buf, tree=None):
307308
return _call_parse(parse_csubstr, buf, tree)
308309

309310
def parse_in_place(buf, tree=None):
310-
"""parse in place a mutable buffer containing YAML. The resulting tree
311+
"""
312+
parse in place a mutable buffer containing YAML. The resulting tree
311313
will point into the given buffer.
312314
313315
:param buf:

0 commit comments

Comments
 (0)