Skip to content

Commit 81a1b84

Browse files
committed
refactor error API: update docs
1 parent ece7d76 commit 81a1b84

6 files changed

Lines changed: 1602 additions & 23 deletions

File tree

changelog/0.8.0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Breaking changes
1+
### Breaking changes
22

33
- [BREAKING] Fix [#480](https://github.com/biojppm/rapidyaml/issues/480) ([PR#489](https://github.com/biojppm/rapidyaml/pull/489)):
44
- Deserializing an empty quoted string *will not* cause an error.
@@ -9,7 +9,7 @@
99
- [BREAKING] Fix [#477](https://github.com/biojppm/rapidyaml/issues/477) ([PR#479](https://github.com/biojppm/rapidyaml/pull/479)): changed `read<std::map>()` to overwrite existing entries. The provided implementations had an inconsistency between `std::map` (which wasn't overwriting) and `std::vector` (which *was* overwriting).
1010

1111

12-
## Fixes
12+
### Fixes
1313

1414
- [PR#488](https://github.com/biojppm/rapidyaml/pull/488):
1515
- add workarounds for problems with codegen of gcc 11,12,13.
@@ -36,7 +36,7 @@
3636
- [PR#499](https://github.com/biojppm/rapidyaml/pull/499): fix warnings with `-Wundef`.
3737

3838

39-
## Thanks
39+
### Thanks
4040

4141
- @ingydotnet
4242
- @perlpunk

changelog/current.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
### Improvements
2+
3+
- [PR#503](https://github.com/biojppm/rapidyaml/pull/503) (fixes [#399](https://github.com/biojppm/rapidyaml/issues/399)): change error callbacks.
4+
- Errors in ryml now have one of these types:
5+
- parse error: when parsing YAML/JSON. See: `pfn_error_parse`, `ErrorDataParse`, `ExceptionParse`, `err_parse_format()`, `sample_error_parse`.
6+
- visit error: when visiting a tree (reading or writing). See: `pfn_error_visit`, `ErrorDataVisit`, `ExceptionVisit`, `err_visit_format()`, `sample_error_visit`.
7+
- basic error: other, non specific errors. See: `pfn_error_basic`, `ErrorDataBasic`, `ExceptionBasic`, `err_basic_format()`, `sample_error_basic`.
8+
- parse and visit errors/exceptions can be treated/caught as basic errors/exceptions
9+
- Add message formatting functions to simplify implementation of error callbacks:
10+
- `err_parse_format()`: format/print a full error message for a parse error
11+
- `err_visit_format()`: format/print a full error message for a visit error
12+
- `err_basic_format()`: format/print a full error message for a basic error
13+
- `location_format()`: format/print a location
14+
- `location_format_with_context()`: useful to create a rich error message showing the YAML region causing the error, maybe even for a visit error if the source is kept and locations are enabled.
15+
- See the new header `c4/yml/error.hpp` (and `c4/yml/error.def.hpp` for definitions of the functions in `c4/yml/error.hpp`)
16+
- See the relevant sample functions in the quickstart sample: `sample_error_basic`, `sample_error_parse` and `sample_error_visit`.
17+
- There are breaking user-facing changes in the `Callbacks` structure:
18+
- Removed member `m_error `
19+
- Added members `m_error_basic`, `m_error_parse`, `m_error_visit`
20+
- Added methods `.set_error_basic()`, `.set_error_parse()` and `.set_error_visit()`.
21+
122

223
### Fixes
324

425
- Fix [#400](https://github.com/biojppm/rapidyaml/issues/400) ([PR#506](https://github.com/biojppm/rapidyaml/pull/506)): clear anchors after resolving.
526
- Fix [#484](https://github.com/biojppm/rapidyaml/issues/484) ([PR#506](https://github.com/biojppm/rapidyaml/pull/506)): fix merge key order for last element to be overriden.
6-
- [PR#503](https://github.com/biojppm/rapidyaml/pull/503): ensure parse error on `a: b: c` and similar cases containing nested maps opening on the same line.
27+
- [PR#504](https://github.com/biojppm/rapidyaml/pull/504): ensure parse error on `a: b: c` and similar cases containing nested maps opening on the same line.
728
- [PR#502](https://github.com/biojppm/rapidyaml/pull/502): fix parse errors or missing tags:
829
- missing tags in empty documents:
930
```yaml

doc/Doxyfile

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -949,20 +949,21 @@ WARN_LOGFILE =
949949
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
950950
# Note: If this tag is empty the current directory is searched.
951951

952-
INPUT = \
953-
./doxy_main.md \
954-
../src \
955-
../test/test_suite/test_suite_event_handler.hpp \
956-
../test/test_suite/test_suite_event_handler.cpp \
957-
../samples/quickstart.cpp \
958-
../ext/c4core/src/c4/substr.hpp \
959-
../ext/c4core/src/c4/charconv.hpp \
960-
../ext/c4core/src/c4/format.hpp \
961-
../ext/c4core/src/c4/base64.hpp \
962-
../ext/c4core/src/c4/utf.hpp \
963-
../ext/c4core/src/c4/std/string.hpp \
964-
../ext/c4core/src/c4/std/string_view.hpp \
965-
../ext/c4core/src/c4/std/vector.hpp \
952+
INPUT = \
953+
./doxy_main.md \
954+
./doxy_changelog.md \
955+
../src \
956+
../test/test_suite/test_suite_event_handler.hpp \
957+
../test/test_suite/test_suite_event_handler.cpp \
958+
../samples/quickstart.cpp \
959+
../ext/c4core/src/c4/substr.hpp \
960+
../ext/c4core/src/c4/charconv.hpp \
961+
../ext/c4core/src/c4/format.hpp \
962+
../ext/c4core/src/c4/base64.hpp \
963+
../ext/c4core/src/c4/utf.hpp \
964+
../ext/c4core/src/c4/std/string.hpp \
965+
../ext/c4core/src/c4/std/string_view.hpp \
966+
../ext/c4core/src/c4/std/vector.hpp \
966967

967968
# This tag can be used to specify the character encoding of the source files
968969
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1099,7 +1100,7 @@ EXCLUDE_SYMBOLS =
10991100
# that contain example code fragments that are included (see the \include
11001101
# command).
11011102

1102-
EXAMPLE_PATH =
1103+
EXAMPLE_PATH = ../changelog
11031104

11041105
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
11051106
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
@@ -1223,7 +1224,7 @@ STRIP_CODE_COMMENTS = NO
12231224
# entity all documented functions referencing it will be listed.
12241225
# The default value is: NO.
12251226

1226-
REFERENCED_BY_RELATION = YES
1227+
REFERENCED_BY_RELATION = NO
12271228

12281229
# If the REFERENCES_RELATION tag is set to YES then for each documented function
12291230
# all documented entities called/used by that function will be listed.

doc/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
99
BUILDDIR = _build
10+
CLANG ?= clang++
11+
DOXYGEN ?= doxygen #/home/jpmag/proj/doxygen/install/linux-x86_64-gxx14.2-Release/bin/doxygen
12+
DOXYGEN_OPTS ?= #-t
1013

1114
# Put it first so that "make" without argument is like "make help".
1215
help:
@@ -28,7 +31,11 @@ doxy:
2831
# ensure submodules are checked out
2932
if [ ! -f $(shell pwd)/../ext/c4core/cmake/c4Project.cmake ] ; then echo "ERROR: submodules not present" ; exit 1 ; fi
3033
if [ ! -f $(shell pwd)/../ext/c4core/src/c4/charconv.hpp ] ; then echo "ERROR: submodules not present" ; exit 1 ; fi
31-
doxygen Doxyfile
34+
## use cmake to generate a compile database
35+
#cmake -S .. -B "$(BUILDDIR)/proj" -DCMAKE_CXX_COMPILER=$(CLANG) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
36+
#ln -fs "$(BUILDDIR)/proj/compile_commands.json" .
37+
## finally, run doxygen
38+
$(DOXYGEN) $(DOXYGEN_OPTS) Doxyfile
3239

3340
clean:
3441
rm -rf doxygen/

0 commit comments

Comments
 (0)