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

Implement way to allow users to handle CallErrors #104

Closed
OrangeTux opened this issue Aug 23, 2020 · 2 comments · Fixed by #124
Closed

Implement way to allow users to handle CallErrors #104

OrangeTux opened this issue Aug 23, 2020 · 2 comments · Fixed by #124
Assignees
Labels
enhancement New feature or request

Comments

@OrangeTux
Copy link
Contributor

Currently ChargePoint.call() returns None when the remote end returns a CallError. That is because ChargePoint.call() silences the CallError.

This is problematic when one wants to act upon receiving a CallError.

I'm not sure yet how and where to change the code so one can handle CallErrors. The easiest way is to change the body of ChargePoint.call() to this:

if response.message_type_id == MessageType.CallError:
    raise response.to_exception()  

But this change is not backwards compatible. In existing code bases one users of this library might need to wrap all there calls to ChargePoint.call() inside try/except to avoid their code from breaking, like:

try:
   self.call(call.HeartbeatPayload())
except ocpp.exceptions.OCPPError as e:
   pass
@OrangeTux OrangeTux added the enhancement New feature or request label Aug 23, 2020
@OrangeTux
Copy link
Contributor Author

OrangeTux commented Oct 6, 2020

In order to main backwards compatibility I suggest to add a keyword argument suppress to ChargePoint.call() that defaults to True.

@tropxy
Copy link
Collaborator

tropxy commented Oct 21, 2020

Fixed in Raise exception if response from call() is CallError #124

@tropxy tropxy closed this as completed Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants