dheera / rosboard

ROS node that turns your robot into a web server to visualize ROS topics
Other
864 stars 164 forks source link

Fixes UnboundLocalError #129

Closed soraxas closed 1 month ago

soraxas commented 1 month ago

When there's exception inside the try except block, the variable img_jpeg would not exists, resulting in UnboundLocalError

    try:
        img = decode_jpeg(bytearray(msg.data))
        ...
        img_jpeg = encode_jpeg(img)               <===== This one most like would not be created
    except Exception as e:
        output["_error"] = "Error: %s" % str(e)
    output["_data_jpeg"] = base64.b64encode(img_jpeg).decode()          <===== This one fails
    output["_data_shape"] = list(original_shape)
dheera commented 1 month ago

Thank you! This is a good catch. Do you have any info on why the exception happened though? I'm wondering if something else needs to also be fixed. Thanks!

soraxas commented 1 month ago

I'm not too sure as I was just testing this out, and haven't continue using it since.

But from the looks of it, it can be as simple as jpeg decode error (e.g. Corrupted /maulform message data?)

dheera commented 1 month ago

OK, thanks anyway!