SmarterJournaledJsonErrorResponse

class smarter.lib.journal.http.SmarterJournaledJsonErrorResponse(request, e, encoder=<class 'smarter.lib.json.SmarterJSONEncoder'>, safe=True, thing=None, command=None, json_dumps_params=None, stack_trace='No stack trace available.', description=None, status=500, **kwargs)[source]

Bases: SmarterJournaledJsonResponse

Enhanced HTTP error response for Smarter CLI commands.

This class serializes error information in a structured JSON format consumable by the Smarter CLI, allowing for consistent error formatting and display in the user console. It is the common error response for all CLI commands.

Parameters:
  • request (HttpRequest) – The original Django request object.

  • e (Optional[Exception]) – The Python exception object that was raised.

  • encoder (type) – JSON encoder class. Defaults to django.core.serializers.json.SmarterJSONEncoder.

  • safe (bool) – Controls if only dict objects may be serialized. Defaults to True.

  • thing (Union[SmarterJournalThings, str, None]) – The resource or entity being operated on (noun).

  • command (Optional[SmarterJournalCliCommands]) – The CLI command executed on the resource.

  • json_dumps_params (Optional[str]) – Additional kwargs for json.dumps().

  • stack_trace (str) – The stack trace for the exception.

  • description (Optional[str]) – Human-readable error description.

  • kwargs – Additional keyword arguments passed to the parent class.

Example error response JSON:

{
    "error": {
        "error_class": "ValueError",
        "stack_trace": "...",
        "description": "Invalid input",
        "status": 400,
        "args": "...",
        "cause": "...",
        "context": "thing=account, command=create"
    }
}
__init__(request, e, encoder=<class 'smarter.lib.json.SmarterJSONEncoder'>, safe=True, thing=None, command=None, json_dumps_params=None, stack_trace='No stack trace available.', description=None, status=500, **kwargs)[source]

Note: this needs to exist.

something in the Python MRO requires it, even if it does nothing. If you remove this, you will get a mysterious error about something downstream expecting exactly one object.