MCPcopy Create free account
hub / github.com/AstrBotDevs/AstrBot / error_response

Function error_response

astrbot/api/web.py:365–387  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

363
364
365def 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
390def file_response(

Callers

nothing calls this directly

Calls 1

json_responseFunction · 0.85

Tested by

no test coverage detected