try:
    msg_json = json.loads(message_string)
    if "task" in msg_json:
        job_type = msg_json["task"]
        return (job_type, msg_json)
    logger.error(
        "Could not parse message: must provide 'task' property",
        extra={"message_string": message_string},
    )
    return empty
except Exception:
    logger.exception(
        "Error parsing JSON message. Did you accidentally double-escape it?",
        extra={"message_string": message_string},
    )
    return empty
I have this code where i am trying to load some JSON formatted message string. After looking back at this piece of code i feel i maybe using try and catch in the wrong way and i was looking for suggestions as i am new to python and there may be cleaner approaches. There is no bug here but this is more for me to learn the "Cleaner" approach. As such i am open to all suggestions that explain the cleaner and more correct approach.
 
    