INNER CODE UNIT · Python
error_code
pineforge-4pass/pineforge-engine · tutorial/run.py:151
def error_code(lib: ctypes.CDLL, state) -> str:
"""'<code> <args JSON>' of the last failure on state, or '' without one."""
if not hasattr(lib, "strategy_get_last_error_code"):
return ""
code = lib.strategy_get_last_error_code(state)
if not code:
return ""
args = (lib.strategy_get_last_error_args(state)
if hasattr(lib, "strategy_get_last_error_args") else None)
return f"{code.decode()} {args.decode() if args else '{}'}"
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 = ""