concrete/src/Http/Service/Ajax.php
public function sendError($error)
    {
        if (@ob_get_length()) {
            @ob_end_clean();
        }
        if ($error instanceof \Concrete\Core\Error\ErrorList\ErrorList) {
            $error->outputJSON();
        } else {
            header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
            header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
            echo($error instanceof Exception) ? $error->getMessage() : $error;
        }
        die();
    }
public function sendError($error)
    {
        if (@ob_get_length()) {
            @ob_end_clean();
        }
        if ($error instanceof \Concrete\Core\Error\ErrorList\ErrorList) {
            $error->outputJSON();
        } else {
            header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
            header('Content-Type: text/plain; charset=' . APP_CHARSET, true);
            echo($error instanceof Exception) ? $error->getMessage() : $error;
        }
        die();
    }
public function sendError ( $ error ) { if ( @ ob_get_length ( ) ) { @ ob_end_clean ( ) ; } if ( $ error instanceof \ Concrete \ Core \ Error \ ErrorList \ ErrorList ) { $ error -> outputJSON ( ) ; } else { header ( $ _SERVER [ 'SERVER_PROTOCOL' ] . ' 400 Bad Request' , true , 400 ) ; header ( 'Content-Type: text/plain; charset=' . APP_CHARSET , true ) ; echo ( $ error instanceof Exception ) ? $ error -> getMessage ( ) : $ error ; } die ( ) ; }
Sends an error to the client and ends the execution.

@param string|Exception|\Concrete\Core\Error\Error $result the error to send to the client
@param mixed $error

@deprecated You should switch to something like:
return \Core::make(\Concrete\Core\Http\ResponseFactoryInterface::class)->json(...)
Sends an error to the client and ends the execution .