public function error($label, $arguments = [])
    {
        $log_message = 'Error code: ' . $label;
        if ($arguments) {
            $log_message .= ', arguments: ' . json_encode($arguments);
        }
        Log::info($log_message);

        if($this->isAjaxRequest()) {
            $error_object = [
                'id' => 'server',
                'code' => '500',
                'message' => $label,
                'arguments' => $arguments
            ];

            echo json_encode([
                'errors' => [$error_object],
            ]);
        } else {
            echo "<h2>Server error: {$label}</h2>";
        }

        exit;
    }
public function error($label, $arguments = [])
    {
        $log_message = 'Error code: ' . $label;
        if ($arguments) {
            $log_message .= ', arguments: ' . json_encode($arguments);
        }
        Log::info($log_message);

        if($this->isAjaxRequest()) {
            $error_object = [
                'id' => 'server',
                'code' => '500',
                'message' => $label,
                'arguments' => $arguments
            ];

            echo json_encode([
                'errors' => [$error_object],
            ]);
        } else {
            echo "<h2>Server error: {$label}</h2>";
        }

        exit;
    }
public function error ( $ label , $ arguments = [ ] ) { $ log_message = 'Error code: ' . $ label ; if ( $ arguments ) { $ log_message .= ', arguments: ' . json_encode ( $ arguments ) ; } Log :: info ( $ log_message ) ; if ( $ this -> isAjaxRequest ( ) ) { $ error_object = [ 'id' => 'server' , 'code' => '500' , 'message' => $ label , 'arguments' => $ arguments ] ; echo json_encode ( [ 'errors' => [ $ error_object ] , ] ) ; } else { echo "<h2>Server error: {$label}</h2>" ; } exit ; }
Echo error message and terminate the application
@param string $label
@param array $arguments
Echo error message and terminate the application