Skip to content

[FEATURE] Expose derived power grid error types #509

Description

@mgovers

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

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
  • 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 PowerGridErrors instead of a list of all error messages individually?
      • This requires also parsing the error code for all individual scenarios in the C API

Activity

  1. moved this to In Discussion for future planning in Power Grid Modelon Feb 29, 2024
  2. moved this from In Discussion for future planning to No status in Power Grid Modelon Mar 26, 2024
  3. moved this from Q3 2026 to Q1 2027 in Power Grid Modelon Jun 17, 2026
  4. moved this from Q1 2027 to Q4 2026 in Power Grid Modelon Oct 14, 2026
  5. added theissue type on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions