Build a standard error response for plugin bridge calls. Args: message: Public error message. status_code: HTTP status code. data: Optional error details that are safe to expose. headers: Optional response headers. Returns: A JSON response with the A
(
message: str,
*,
status_code: int = 400,
data: Any = None,
headers: dict[str, str] | None = None,
)
| 363 | |
| 364 | |
| 365 | def error_response( |
| 366 | message: str, |
| 367 | *, |
| 368 | status_code: int = 400, |
| 369 | data: Any = None, |
| 370 | headers: dict[str, str] | None = None, |
| 371 | ) -> JSONResponse: |
| 372 | """Build a standard error response for plugin bridge calls. |
| 373 | |
| 374 | Args: |
| 375 | message: Public error message. |
| 376 | status_code: HTTP status code. |
| 377 | data: Optional error details that are safe to expose. |
| 378 | headers: Optional response headers. |
| 379 | |
| 380 | Returns: |
| 381 | A JSON response with the AstrBot error envelope. |
| 382 | """ |
| 383 | return json_response( |
| 384 | {"status": "error", "message": message, "data": data}, |
| 385 | status_code=status_code, |
| 386 | headers=headers, |
| 387 | ) |
| 388 | |
| 389 | |
| 390 | def file_response( |
nothing calls this directly
no test coverage detected