INNER CODE UNIT · Python

run_error

pineforge-4pass/pineforge-engine · tutorial/run.py:163

def run_error(lib: ctypes.CDLL, state) -> str | None:
    """'<text> (<code> <args JSON>)' when the run just made on state failed, else
    None. A run failed when the engine reports a text, a code or a run status of 1
    (strategy_last_run_status), as docker/run_json.py decides, so a script stopped
    by runtime.error("") fails instead of printing a result."""
    text = ""
    if hasattr(lib, "strategy_get_last_error"):
        raw = lib.strategy_get_last_error(state)
        text = raw.decode("utf-8", "replace") if raw else ""
    code = error_code(lib, state)
    status = (lib.strategy_last_run_status(state)
              if hasattr(lib, "strategy_last_run_status") else 0)
    if not (text or code or status == 1):
        return None
    if not (text or code):
        text = "the run did not complete and the engine reported no error"
    return " ".join(part for part in (text, f"({code})" if code else "") if part)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…