(operation, *, prefix: str)
| 62 | |
| 63 | |
| 64 | async def _run(operation, *, prefix: str): |
| 65 | try: |
| 66 | result = await run_maybe_async(operation) |
| 67 | if isinstance(result, tuple): |
| 68 | data, message = result |
| 69 | return ok(data, message) |
| 70 | return ok(result) |
| 71 | except (KnowledgeBaseServiceError, ValueError) as exc: |
| 72 | return error(str(exc)) |
| 73 | except Exception as exc: |
| 74 | logger.error("%s: %s", prefix, exc, exc_info=True) |
| 75 | return error(f"{prefix}: {exc!s}") |
| 76 | |
| 77 | |
| 78 | async def _run_json( |
no test coverage detected