diff --git a/app/Misc/Helper.php b/app/Misc/Helper.php index a84e6c0d..1af70fd7 100644 --- a/app/Misc/Helper.php +++ b/app/Misc/Helper.php @@ -765,6 +765,18 @@ class Helper ->log($description); } + /** + * Log exception to activity log. + */ + public static function logExceptionToActivityLog($e, $log_name, $description, $properties = []) + { + $properties['error'] = self::formatException($e); + activity() + ->withProperties($properties) + ->useLog($log_name) + ->log($description); + } + /** * Check if folder is writable. * diff --git a/overrides/Webklex/IMAP/Message.php b/overrides/Webklex/IMAP/Message.php index b3a49f81..75a7e1d8 100644 --- a/overrides/Webklex/IMAP/Message.php +++ b/overrides/Webklex/IMAP/Message.php @@ -396,6 +396,10 @@ class Message } catch (\Exception $_e) { $this->date = Carbon::now(); \Helper::logException($_e, '[Webklex\IMAP\Message]'); + \Helper::logExceptionToActivityLog($_e, + \App\ActivityLog::NAME_EMAILS_FETCHING, + \App\ActivityLog::DESCRIPTION_EMAILS_FETCHING_ERROR + ); //throw new InvalidMessageDateException("Invalid message date. ID:".$this->getMessageId(), 1000, $e); } } @@ -831,6 +835,10 @@ class Message return $this->convertEncoding($str, $from, $to); } else { \Helper::logException($e, '[Webklex\IMAP\Message]'); + \Helper::logExceptionToActivityLog($e, + \App\ActivityLog::NAME_EMAILS_FETCHING, + \App\ActivityLog::DESCRIPTION_EMAILS_FETCHING_ERROR + ); return $str; } }