Back

try / catch, insertLog Function

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

try{ $this->dsdffdfd; } catch (\Exception $e) { insertLog($e, 'normal'); } function insertLog($e, $priority = 'normal') { $obj = new App\Models\Log(); $obj->saveDb($e->getMessage(), $e->getFile(), $priority); $exception = new ExceptionLogger(); $exception->logException($e->getFile(), $e); sendLogNotification($e->getMessage(), $e->getFile(), $priority); } function sendLogNotification($error, $file, $priority) { if ($priority != 'critical') { return false; } $email_subject = 'Exception in ' . siteName(); $emailBody = '<table><tr><td><h6>Error: <strong>' . $error . '</strong></h6></td></tr><tr><td><h6>File: <strong>' . $file . '</strong></h6></td></tr></table>'; Mail::send( array(), array(), function ($message) use ($emailBody, $email_subject) { $message->to(['waqas0345@gmail.com']) ->subject($email_subject) ->from('admin@' . siteDomain()) ->setBody($emailBody, 'text/html'); } ); return true; }