parameters: (
      endpoint: str,
      detail: str,
      code: str = "invalid",
      type: str = "validation_error",
      attr: Optional[str] = None,
      status_code: int = status.HTTP_400_BAD_REQUEST,
  )
return_statement: return JsonResponse({"type": type, "code": code, "detail": detail, "attr": attr}, status=status_code,)
docstring: Generates a friendly JSON error response in line with drf-exceptions-hog for endpoints not under DRF.
docstring_summary: Generates a friendly JSON error response in line with drf-exceptions-hog for endpoints not under DRF.
docstring_tokens: Generates a friendly JSON error response in line with drf - exceptions - hog for endpoints not under DRF .
function: def generate_exception_response(
      endpoint: str,
      detail: str,
      code: str = "invalid",
      type: str = "validation_error",
      attr: Optional[str] = None,
      status_code: int = status.HTTP_400_BAD_REQUEST,
  ) -> JsonResponse:
      """
      Generates a friendly JSON error response in line with drf-exceptions-hog for endpoints not under DRF.
      """
  
      from posthog.internal_metrics import incr
  
      incr(f"posthog_cloud_raw_endpoint_exception", tags={"endpoint": endpoint, "code": code, "type": type, "attr": attr})
      return JsonResponse({"type": type, "code": code, "detail": detail, "attr": attr}, status=status_code,)
function_tokens: def generate_exception_response ( endpoint : str , detail : str , code : str = "invalid" , type : str = "validation_error" , attr : Optional [ str ] = None , status_code : int = status . HTTP_400_BAD_REQUEST , ) -> JsonResponse : from posthog . internal_metrics import incr incr ( f"posthog_cloud_raw_endpoint_exception" , tags = { "endpoint" : endpoint , "code" : code , "type" : type , "attr" : attr } ) return JsonResponse ( { "type" : type , "code" : code , "detail" : detail , "attr" : attr } , status = status_code , )