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

Translating OpenDSS Errors into exceptions #50

Closed
PMeira opened this issue May 23, 2019 · 0 comments · Fixed by #54
Closed

Translating OpenDSS Errors into exceptions #50

PMeira opened this issue May 23, 2019 · 0 comments · Fixed by #54

Comments

@PMeira
Copy link
Member

PMeira commented May 23, 2019

The idea is just to check if Error.Number() (or the contents of the Error pointer directly) is non-zero, mapping Error.Description() into an exception frequently. This should avoid many issues since there are many places that use the Error interface to report errors in the Pascal code.

Adding this shouldn't be too hard. First we need to move this snippet into a new function:

error_num = Lib.Error_Get_Number()
if (error_num != 0)
description = Utils.get_string(Lib.Error_Get_Description())
throw(
OpenDSSDirectException(
"[ERROR $error_num] $description"
)
)
end

Then,

  1. insert calls to it through the code as I've been doing for the other projects, or
  2. use a macro to wrap (nearly) all functions somehow

A similar approach is already being used in DSS Python/MATLAB.

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

Successfully merging a pull request may close this issue.

1 participant