Skip to content

We need to pass-thru the ERROR messages in a better way to the Python package #1

@vsenderov

Description

@vsenderov

For example, from Python:

$ python3 experiment.py data/jeremy-crbd__12.1.a-1.json data/prior.json
Traceback (most recent call last):
  File "/home/viktor/treeppl-python/treeppl/base.py", line 72, in __init__
    result = from_json(stdout)
  File "/home/viktor/treeppl-python/treeppl/serialization.py", line 41, in from_json
    return json.load(fp, object_hook=object_hook)
  File "/usr/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.10/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/c/Users/senderov/Sync/Workspaces/Q-T-Birds/experiments/sprint15/experiment.py", line 54, in <module>
    res = qtbirds( tree=tree
  File "/home/viktor/treeppl-python/treeppl/base.py", line 66, in __call__
    return InferenceResult(proc.stdout)
  File "/home/viktor/treeppl-python/treeppl/base.py", line 74, in __init__
    raise InferenceError("Could not parse the output from TreePPL.")
treeppl.exceptions.InferenceError: Could not parse the output from TreePPL.

It is not obvious what the error is. But from the command-line:

$ ./out input.json
ERROR <qtbirds.tppl 217:35-217:45>:
Field 'rigth' not found
  let rightTime = getAgeDiff(tree, tree.rigth);
viktor@BDWF26:~/qtbirds.tppl$

you see that we just misspelled right as rigth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions