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

[LG-71] Improvements to error handling #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Commits on Nov 22, 2024

  1. Configuration menu
    Copy the full SHA
    cecc81c View commit details
    Browse the repository at this point in the history
  2. Introduce WirepasMessage base class

    This refactoring is made in order to make it easier to introduce
    stricter checks during message decoding.
    
    Request, Response, and Event classes are now inheriting the
    WirepasMessage class. The class handles decoding of a message using the
    _get_related_message() method which should be implemented by each child
    class.
    sgunes-wirepas committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    c66bfe9 View commit details
    Browse the repository at this point in the history
  3. Add stricter checking when decoding with .from_payload()

    Earlier, it was possible that a protobuf payload not including a certain
    message was decoded using .from_payload(). For example when using
    GetConfigsRequest.from_payload() with a message missing
    GenericMessage::wirepas::get_configs_req, the library was not reporting
    an error and setting the req_id to 0 even though it was not initialized
    in the protobuf message.
    
    If that happens now, and InvalidMessageType exception is raised. This
    exception has the GatewayAPIParsingException as its parent to help with
    backwards compatibility.
    
    Also refactoring the tests and having a new test file for decoding
    related error testing.
    sgunes-wirepas committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    afa7ad0 View commit details
    Browse the repository at this point in the history
  4. Improve errors for SetScratchpadTargetAndActionRequest.from_payload()

    If constructing a new SetScratchpadTargetAndActionRequest from payload
    fails due to invalid values, a new InvalidMessageContents exception is
    raised. This exception can hold the header of the request message, and
    it would be possible to generate a response with the corresponding
    req_id based on the exception.
    sgunes-wirepas committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    400b1e8 View commit details
    Browse the repository at this point in the history