public function exception(\Exception $e)
    {
        $fields = [];

        $addToField = function($name, $value, $short = false) use (&$fields) {
            if (!empty($value)) {
                $fields[] = [
                    'title' => $name,
                    'value' => $value,
                    'short' => $short,
                ];
            }
        };

        $addToField('Environment', app()->environment(), true);
        $addToField('Exception', get_class($e), true);
        $addToField(
            'Http code',
            $e instanceof \Symfony\Component\HttpKernel\Exception\HttpException ? $e->getStatusCode() : 500,
            true
        );
        $addToField('Code', $e->getCode(), true);
        $addToField('File', $e->getFile(), true);
        $addToField('Line', $e->getLine(), true);
        $addToField('Request url', request()->url(), true);
        $addToField('Request method', request()->method(), true);
        $addToField('Request param', json_encode(request()->all()), true);

        $message    = ':bug: Error Occurs on '.app()->environment();
        $type       = 'serious-alert';
        $pretext    = 'Error Occurs on '.app()->environment();
        $attachment = [
            'color'    => 'danger',
            'title'    => $e->getMessage(),
            'fallback' => !empty($e->getMessage()) ? $e->getMessage() : get_class($e),
            'pretext'  => $pretext,
            'fields'   => $fields,
            'text'     => $e->getTraceAsString(),
        ];

        // notify to slack
        $this->post($message, $type, $attachment);
    }
public function exception(\Exception $e)
    {
        $fields = [];

        $addToField = function($name, $value, $short = false) use (&$fields) {
            if (!empty($value)) {
                $fields[] = [
                    'title' => $name,
                    'value' => $value,
                    'short' => $short,
                ];
            }
        };

        $addToField('Environment', app()->environment(), true);
        $addToField('Exception', get_class($e), true);
        $addToField(
            'Http code',
            $e instanceof \Symfony\Component\HttpKernel\Exception\HttpException ? $e->getStatusCode() : 500,
            true
        );
        $addToField('Code', $e->getCode(), true);
        $addToField('File', $e->getFile(), true);
        $addToField('Line', $e->getLine(), true);
        $addToField('Request url', request()->url(), true);
        $addToField('Request method', request()->method(), true);
        $addToField('Request param', json_encode(request()->all()), true);

        $message    = ':bug: Error Occurs on '.app()->environment();
        $type       = 'serious-alert';
        $pretext    = 'Error Occurs on '.app()->environment();
        $attachment = [
            'color'    => 'danger',
            'title'    => $e->getMessage(),
            'fallback' => !empty($e->getMessage()) ? $e->getMessage() : get_class($e),
            'pretext'  => $pretext,
            'fields'   => $fields,
            'text'     => $e->getTraceAsString(),
        ];

        // notify to slack
        $this->post($message, $type, $attachment);
    }
public function exception ( \ Exception $ e ) { $ fields = [ ] ; $ addToField = function ( $ name , $ value , $ short = false ) use ( & $ fields ) { if ( ! empty ( $ value ) ) { $ fields [ ] = [ 'title' => $ name , 'value' => $ value , 'short' => $ short , ] ; } } ; $ addToField ( 'Environment' , app ( ) -> environment ( ) , true ) ; $ addToField ( 'Exception' , get_class ( $ e ) , true ) ; $ addToField ( 'Http code' , $ e instanceof \ Symfony \ Component \ HttpKernel \ Exception \ HttpException ? $ e -> getStatusCode ( ) : 500 , true ) ; $ addToField ( 'Code' , $ e -> getCode ( ) , true ) ; $ addToField ( 'File' , $ e -> getFile ( ) , true ) ; $ addToField ( 'Line' , $ e -> getLine ( ) , true ) ; $ addToField ( 'Request url' , request ( ) -> url ( ) , true ) ; $ addToField ( 'Request method' , request ( ) -> method ( ) , true ) ; $ addToField ( 'Request param' , json_encode ( request ( ) -> all ( ) ) , true ) ; $ message = ':bug: Error Occurs on ' . app ( ) -> environment ( ) ; $ type = 'serious-alert' ; $ pretext = 'Error Occurs on ' . app ( ) -> environment ( ) ; $ attachment = [ 'color' => 'danger' , 'title' => $ e -> getMessage ( ) , 'fallback' => ! empty ( $ e -> getMessage ( ) ) ? $ e -> getMessage ( ) : get_class ( $ e ) , 'pretext' => $ pretext , 'fields' => $ fields , 'text' => $ e -> getTraceAsString ( ) , ] ; // notify to slack $ this -> post ( $ message , $ type , $ attachment ) ; }
Report an exception to slack.

@param \Exception $e
Report an exception to slack .