Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign Exception classes w/ boost::exception #219

Closed
rakhimov opened this issue Aug 23, 2017 · 0 comments
Closed

Redesign Exception classes w/ boost::exception #219

rakhimov opened this issue Aug 23, 2017 · 0 comments
Labels
Milestone

Comments

@rakhimov
Copy link
Owner

rakhimov commented Aug 23, 2017

The current scram exception classes
are string-ly context & error carriers,
which are noexcept-incorrect, localization unfriendly, and inflexible.
For example, dealing with libxml2 errors in this manner is a nightmare.

Boost exception library provides a solid framework
to properly design exception classes.

  • No error message construction at throw site
  • Provide more context data
  • Build the context data incrementally
  • Generic
  • Error message construction only at report site (front-ends)
  • Coherent and consistent design

The new design should help with proper libxml2 error extraction (#218)
and translation & localization of error messages (#216).

@rakhimov rakhimov added this to the v0.16.0 milestone Aug 23, 2017
rakhimov added a commit that referenced this issue Oct 15, 2017
This uses virtual inheritance to derive from std::exception as well.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This should replace the dynamic messages generated at throw site.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This is a helper macro to add more information
about the exception source.
Unlike BOOST_THROW_EXCEPTION,
SCRAM_THROW assumes that the exceptions derive from boost::exception.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
Instead of using macro to stringify the exception types,
use boost::core::demangled_name to get the exception type name.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
File and line numbers can be attached as tagged data.
This removes the need for constructing message strings at throw site.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
rakhimov added a commit that referenced this issue Oct 15, 2017
For the analysis settings,
it is more specific to use custom exception class.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This is needed to further refine the data passed to exceptions.
The MEF specific validation errors should be used
instead of generic InvalidArgument error class.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This is in parallel to XML ValidityError.
Validation is a process,
so ValidationError would be confusing the process
with the actual model invariants (i.e., validity).

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
The MEF facilities deal with validating the model input and values.
InvalidArgument is too general.
The values are checked with validity tests,
and upon error, ValidityError is issued.

The DomainError helps validating Expression intervals.
This also removes the slicing code
converting InvalidArgument to ValidityError.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This exception is too broad and has been misused.
Instead, use the new MEF validity exceptions.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
IllegalOperations are expected violations by users.
Other functionalities are LogicErrors.
Only CCF group code is needed to be switched to LogicError.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
Instead of showing all the invalid events and CCF groups,
a single invalid entity is shown as soon as it is detected.
This is in the same spirit as the other validation steps.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This is helpful to indicate the DL problems explicitly.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
File name, open mode, and error code
can be transferred with existing boost exception tags.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
MEF containers can act as namespaces
to clarify the error location.
This is currently used for event trees.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This is a more explicit way
to indicate unexpected internal logic errors.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
The SCRAM specific identifier is redundant.
Boost exception reporting dynamically prints the exception type.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This tag has been a redundant way to specify the exception message.
The removal simplifies the Error class.
error.cc has become empty and unnecessary as well after this change.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This XML error class differentiates errors from mef::ValidityError.
The tags identify XML element and attribute names.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This removes the anti-pattern of string-ly carrying the context.
The context needs to be built with boost exception tags instead.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
The macro adds function, source line and file information
to the diagnostic information.
This is similar to BOOST_THROW_EXCEPTION,
but it only works with SCRAM exceptions.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
The reason for catching only on Release mode
was the loss of exception type information.
Now with Boost exception and RTTI,
this information can be retrieved without loss,
so the Debug mode does not need to crash.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
This checks the ABI version for libxml2.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
The libxml2 library errors are converted into
boost::exception based errors
that carry the context in boost exception tags.
Parsing, validation, RNG, XInclude code reworked
to properly carry information from libxml2 xmlGetLastError.

However, libxml2 still prints its own error messages in stderr.
This needs to be configured separately for higher message verbosity.

Issue #219
rakhimov added a commit that referenced this issue Oct 15, 2017
These errors are not meant to be translated.
The maximum verbosity is desired for debugging purposes.

Issue #219
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant