Repository navigation
Labels
featureNew feature or requestNew feature or request
Description
Describe the feature request
Expose all different error types thrown by the calculation core as separate error classes that derive from PowerGridError.
Rationale
Currently, all power grid errors are derived from PowerGridError. The only difference between e.g. SparseMatrixError and IterationDivergeError is the string message of the error. As a user, parsing strings (that may change in the future) is suboptimal compared to actual different errors derived from the PowerGridError.
First iteration
- Python side: done in Feature/separate python error types #546 and documentation for error types #552
- Create separate error classes, e.g.
class SparseMatrixError(PowerGridError): """Sparse matrix error class.""" pass
- Look at the cpp errors which ones are necessary
- Obtain the correct error
- Short term solution: parse from the error message string
- Look through all cpp errors to make sure all error message are used.
- There may be multiple error strings for one error type
- Make sure all string combinations are parsed
- There may be cases where the same string is used for different error types
- Make sure that all error cases in cpp are handled correctly
- Short term solution: parse from the error message string
Next step
See proposal in #1635
Design
See proposal in #1635
- Python side
- Use classes provided by the first iteration part
- Obtain the correct error
- Sustainable solution: raise the correct error from the C API (see below)
- C API
- Define other error codes for all error types defined in
exceptions.hpp - Update the
call_with_catchto produce the correct error code based on the raised exception.- Use a Lippincott pattern (see e.g. on usage)
power-grid-model/power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp
Line 574 in 037a0e4
static auto scenario_exception_handler(MainModelImpl& model, std::vector<std::string>& messages,
- Use a Lippincott pattern (see e.g.
- Define other error codes for all error types defined in
- Main Model
- Update logic so that the correct errors are provided for each scenario batch in a batch
TBD
See proposal in #1635
- How to handle batch errors?
- Should that be done by adding a vector with all error codes?
- Are those error codes known by the C++ core?
- Or should it be a vector of
PowerGridErrorsinstead of a list of all error messages individually?- This requires also parsing the error code for all individual scenarios in the C API
- Should that be done by adding a vector with all error codes?
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request
Type
Projects
- StatusShow more project fieldsQ4 2026
Activity