You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A `KeyError` was raised to indicate errors while getting inverters for
batteries, but this have a couple of issues.
First, the `KeyError` was converted to a string to get an error message,
but `KeyError` is a very special error, and the argument is interpreted
as a *key*, not as an error message, so when converting the error to a
`str`, the result is the `repr()` of the *key*, so the strings are
quoted and escaped, which is not what we want to report errors
downstream.
Second, one of the reported errors isn't really a `KeyError`, it is just
a mismatch between what is requested and the current microgrid topology,
so using a `KeyError` was completely wrong.
Since these errors were only used to report errors from a direct call,
we change `_get_components_data()` to return `list[InvBatPair] | str`,
where if there is an error, a `str` with the error description is
returned directly.
As an extra, we sort the IDs when used in error messages, so they are
easier to read for users, and more deterministic for tests.
Tests are also simplified to remove the use of regex, which were
probably only used because string were quoted.
Signed-off-by: Leandro Lucarella <[email protected]>
0 commit comments