From 8d9ae2a10b20e88dbd4dc593eb98564c995a61ca Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Sun, 10 Dec 2023 20:21:43 +0300 Subject: [PATCH] Converted Exception messages to be more meaningful. --- src/Backends/Common/CommonTrait.php | 8 +- src/Backends/Emby/Action/ParseWebhook.php | 9 +- src/Backends/Emby/Action/Progress.php | 22 ++++- src/Backends/Jellyfin/Action/Backup.php | 11 ++- src/Backends/Jellyfin/Action/Export.php | 11 ++- src/Backends/Jellyfin/Action/Import.php | 89 ++++++++++++----- src/Backends/Jellyfin/Action/ParseWebhook.php | 9 +- src/Backends/Jellyfin/Action/Progress.php | 22 ++++- src/Backends/Jellyfin/Action/Push.php | 22 ++++- src/Backends/Jellyfin/JellyfinGuid.php | 11 ++- src/Backends/Plex/Action/Backup.php | 11 ++- src/Backends/Plex/Action/Export.php | 11 ++- src/Backends/Plex/Action/GetLibrary.php | 9 +- src/Backends/Plex/Action/GetUserToken.php | 9 +- src/Backends/Plex/Action/Import.php | 96 ++++++++++++++----- src/Backends/Plex/Action/ParseWebhook.php | 9 +- src/Backends/Plex/Action/Progress.php | 22 ++++- src/Backends/Plex/Action/Push.php | 22 ++++- src/Backends/Plex/PlexGuid.php | 22 ++++- src/Commands/Backend/RestoreCommand.php | 4 +- src/Commands/State/ExportCommand.php | 10 +- src/Commands/State/ProgressCommand.php | 10 +- src/Commands/State/PushCommand.php | 10 +- 23 files changed, 367 insertions(+), 92 deletions(-) diff --git a/src/Backends/Common/CommonTrait.php b/src/Backends/Common/CommonTrait.php index f8aa348b..a71ad26d 100644 --- a/src/Backends/Common/CommonTrait.php +++ b/src/Backends/Common/CommonTrait.php @@ -33,12 +33,18 @@ trait CommonTrait return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown in [{client}: {backend}] {action}. {message}', + message: 'Exception [{error.kind}] was thrown unhandled in [{client}: {backend}] {action}. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'action' => $action ?? 'context', 'backend' => $context->backendName, 'client' => $context->clientName, 'message' => $e->getMessage(), + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Backends/Emby/Action/ParseWebhook.php b/src/Backends/Emby/Action/ParseWebhook.php index 6d5bbea2..24f75e14 100644 --- a/src/Backends/Emby/Action/ParseWebhook.php +++ b/src/Backends/Emby/Action/ParseWebhook.php @@ -232,9 +232,16 @@ final class ParseWebhook return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown during [{backend}] webhook event parsing.', + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] webhook event parsing. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Backends/Emby/Action/Progress.php b/src/Backends/Emby/Action/Progress.php index a28bd8cc..595614a0 100644 --- a/src/Backends/Emby/Action/Progress.php +++ b/src/Backends/Emby/Action/Progress.php @@ -157,10 +157,17 @@ class Progress } } catch (\RuntimeException $e) { $this->logger->error( - 'Unhandled exception was thrown during request to get [{backend}] {item.type} [{item.title}] status.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] get {item.type} [{item.title}] status. Error [{error.message} @ {error.file}:{error.line}].', + contexT: [ 'backend' => $context->backendName, + 'client' => $context->clientName, ...$logContext, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), @@ -213,9 +220,16 @@ class Progress } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during request to change [{backend}] {item.type} [{item.title}] watch progress.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] change {item.type} [{item.title}] watch progress. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/Action/Backup.php b/src/Backends/Jellyfin/Action/Backup.php index 0e1dc966..dcb4530b 100644 --- a/src/Backends/Jellyfin/Action/Backup.php +++ b/src/Backends/Jellyfin/Action/Backup.php @@ -145,9 +145,16 @@ class Backup extends Import } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] backup.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] backup. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/Action/Export.php b/src/Backends/Jellyfin/Action/Export.php index a70f25c9..bde52d34 100644 --- a/src/Backends/Jellyfin/Action/Export.php +++ b/src/Backends/Jellyfin/Action/Export.php @@ -237,9 +237,16 @@ class Export extends Import ); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] export.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] export. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/Action/Import.php b/src/Backends/Jellyfin/Action/Import.php index 7cef6091..1a9b9fd6 100644 --- a/src/Backends/Jellyfin/Action/Import.php +++ b/src/Backends/Jellyfin/Action/Import.php @@ -71,9 +71,16 @@ class Import logContext: $logContext ), error: fn(array $logContext = []) => fn(Throwable $e) => $this->logger->error( - 'Unhandled Exception was thrown during [{backend}] library [{library.title}] request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] library [{library.title}] request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -171,16 +178,26 @@ class Import Message::add("{$context->backendName}.has_errors", true); return []; } catch (Throwable $e) { - $this->logger->error('Unhandled exception was thrown during request for [{backend}] libraries.', [ - 'backend' => $context->backendName, - 'exception' => [ - 'file' => $e->getFile(), - 'line' => $e->getLine(), - 'kind' => get_class($e), - 'message' => $e->getMessage(), - 'trace' => $context->trace ? $e->getTrace() : [], - ], - ]); + $this->logger->error( + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for libraries. Error [{error.message} @ {error.file}:{error.line}].', + context: [ + 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], + 'exception' => [ + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'kind' => get_class($e), + 'message' => $e->getMessage(), + 'trace' => $context->trace ? $e->getTrace() : [], + ], + ] + ); Message::add("{$context->backendName}.has_errors", true); return []; } @@ -257,9 +274,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] items count request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] items count request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -401,9 +425,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] series external ids request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] series external ids request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -530,9 +561,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] [{segment.number}/{segment.of}] content list request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] [{segment.number}/{segment.of}] content list request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -636,8 +674,8 @@ class Import } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during parsing of [{backend}] library [{library.title}] [{segment.number}/{segment.of}] response.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing [{library.title}] [{segment.number}/{segment.of}] response. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, ...$logContext, 'exception' => [ @@ -851,9 +889,16 @@ class Import ]); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] import.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] [{item.title}] import. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/Action/ParseWebhook.php b/src/Backends/Jellyfin/Action/ParseWebhook.php index c4004466..d766c6aa 100644 --- a/src/Backends/Jellyfin/Action/ParseWebhook.php +++ b/src/Backends/Jellyfin/Action/ParseWebhook.php @@ -216,9 +216,16 @@ final class ParseWebhook return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown during [{backend}] webhook event parsing.', + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] webhook event parsing. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Backends/Jellyfin/Action/Progress.php b/src/Backends/Jellyfin/Action/Progress.php index b19542ac..db3d8220 100644 --- a/src/Backends/Jellyfin/Action/Progress.php +++ b/src/Backends/Jellyfin/Action/Progress.php @@ -157,9 +157,16 @@ class Progress } } catch (\RuntimeException $e) { $this->logger->error( - 'Unhandled exception was thrown during request to get [{backend}] {item.type} [{item.title}] status.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] get {item.type} [{item.title}] status. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -210,9 +217,16 @@ class Progress } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during request to change [{backend}] {item.type} [{item.title}] watch progress.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] change {item.type} [{item.title}] watch progress. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/Action/Push.php b/src/Backends/Jellyfin/Action/Push.php index 8c613516..d424b732 100644 --- a/src/Backends/Jellyfin/Action/Push.php +++ b/src/Backends/Jellyfin/Action/Push.php @@ -118,9 +118,16 @@ class Push ); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during request for [{backend}] {item.type} [{item.title}] metadata.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for {item.type} [{item.title}] metadata. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -293,9 +300,16 @@ class Push } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] {item.type} [{item.title}].', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing [{library.title}] [{segment.number}/{segment.of}] response. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Jellyfin/JellyfinGuid.php b/src/Backends/Jellyfin/JellyfinGuid.php index bb1a76a3..0c430ae5 100644 --- a/src/Backends/Jellyfin/JellyfinGuid.php +++ b/src/Backends/Jellyfin/JellyfinGuid.php @@ -106,9 +106,16 @@ class JellyfinGuid implements iGuid } catch (Throwable $e) { if (true === $log) { $this->logger->error( - 'Unhandled exception was thrown in parsing of [{backend}] [{agent}] identifier.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing [{agent}] identifier. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $this->context->backendName, + 'client' => $this->context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'agent' => $value, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/Action/Backup.php b/src/Backends/Plex/Action/Backup.php index 4f5bc75e..3854cbdc 100644 --- a/src/Backends/Plex/Action/Backup.php +++ b/src/Backends/Plex/Action/Backup.php @@ -150,9 +150,16 @@ final class Backup extends Import } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] backup.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] backup. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/Action/Export.php b/src/Backends/Plex/Action/Export.php index bdc3e618..d960a9d8 100644 --- a/src/Backends/Plex/Action/Export.php +++ b/src/Backends/Plex/Action/Export.php @@ -242,9 +242,16 @@ final class Export extends Import ); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] export.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] backup. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/Action/GetLibrary.php b/src/Backends/Plex/Action/GetLibrary.php index 21e5f2aa..37ecd5f6 100644 --- a/src/Backends/Plex/Action/GetLibrary.php +++ b/src/Backends/Plex/Action/GetLibrary.php @@ -242,9 +242,16 @@ final class GetLibrary return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown during request for [{backend}] {item.type} [{item.title}] metadata.', + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for {item.type} [{item.title}] metadata. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Backends/Plex/Action/GetUserToken.php b/src/Backends/Plex/Action/GetUserToken.php index 5a9007eb..a678c214 100644 --- a/src/Backends/Plex/Action/GetUserToken.php +++ b/src/Backends/Plex/Action/GetUserToken.php @@ -209,9 +209,16 @@ final class GetUserToken return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown during request for [{backend}] [{username}] access token.', + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for [{username}] access token. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'username' => $username, 'user_id' => $userId, 'exception' => [ diff --git a/src/Backends/Plex/Action/Import.php b/src/Backends/Plex/Action/Import.php index fb785109..63174eea 100644 --- a/src/Backends/Plex/Action/Import.php +++ b/src/Backends/Plex/Action/Import.php @@ -71,9 +71,16 @@ class Import logContext: $logContext ), error: fn(array $logContext = []) => fn(Throwable $e) => $this->logger->error( - 'Unhandled Exception was thrown during [{backend}] library [{library.title}] request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] library [{library.title}] request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -176,16 +183,26 @@ class Import Message::add("{$context->backendName}.has_errors", true); return []; } catch (Throwable $e) { - $this->logger->error('Unhandled exception was thrown during request for [{backend}] libraries.', [ - 'backend' => $context->backendName, - 'exception' => [ - 'file' => $e->getFile(), - 'line' => $e->getLine(), - 'kind' => get_class($e), - 'message' => $e->getMessage(), - 'trace' => $context->trace ? $e->getTrace() : [], - ], - ]); + $this->logger->error( + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for libraries. Error [{error.message} @ {error.file}:{error.line}].', + context: [ + 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], + 'exception' => [ + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'kind' => get_class($e), + 'message' => $e->getMessage(), + 'trace' => $context->trace ? $e->getTrace() : [], + ], + ] + ); Message::add("{$context->backendName}.has_errors", true); return []; } @@ -310,9 +327,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] items count request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] items count request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -481,9 +505,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] [{segment.number}/{segment.of}] series external ids request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] [{segment.number}/{segment.of}] series external ids request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -617,9 +648,16 @@ class Import continue; } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during [{backend}] [{library.title}] [{segment.number}/{segment.of}] content list request.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] [{segment.number}/{segment.of}] content list request. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -715,9 +753,16 @@ class Import } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during parsing of [{backend}] library [{library.title}] [{segment.number}/{segment.of}] response.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing of [{library.title}] [{segment.number}/{segment.of}] response. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -936,9 +981,16 @@ class Import ]); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] [{library.title}] [{item.title}] import.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] [{library.title}] [{item.title}] import. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/Action/ParseWebhook.php b/src/Backends/Plex/Action/ParseWebhook.php index 880db77b..996d0f8b 100644 --- a/src/Backends/Plex/Action/ParseWebhook.php +++ b/src/Backends/Plex/Action/ParseWebhook.php @@ -228,9 +228,16 @@ final class ParseWebhook return new Response( status: false, error: new Error( - message: 'Unhandled exception was thrown during [{backend}] webhook event parsing.', + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] webhook event parsing. Error [{error.message} @ {error.file}:{error.line}].', context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'exception' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), diff --git a/src/Backends/Plex/Action/Progress.php b/src/Backends/Plex/Action/Progress.php index ae46f1bd..8b9585db 100644 --- a/src/Backends/Plex/Action/Progress.php +++ b/src/Backends/Plex/Action/Progress.php @@ -162,9 +162,16 @@ class Progress } } catch (\RuntimeException $e) { $this->logger->error( - 'Unhandled exception was thrown during request to get [{backend}] {item.type} [{item.title}] status.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request to get {item.type} [{item.title}] status. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), @@ -213,9 +220,16 @@ class Progress } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during request to change [{backend}] {item.type} [{item.title}] watch progress.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request to change {item.type} [{item.title}] watch progress. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/Action/Push.php b/src/Backends/Plex/Action/Push.php index 3503e69d..c1e8e52e 100644 --- a/src/Backends/Plex/Action/Push.php +++ b/src/Backends/Plex/Action/Push.php @@ -105,9 +105,16 @@ final class Push ); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during request for [{backend}] {item.type} [{item.title}] metadata.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] request for {item.type} [{item.title}] metadata. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => after($e->getFile(), ROOT_PATH), @@ -291,9 +298,16 @@ final class Push } } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception was thrown during handling of [{backend}] {item.type} [{item.title}].', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] push. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $context->backendName, + 'client' => $context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$logContext, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Backends/Plex/PlexGuid.php b/src/Backends/Plex/PlexGuid.php index bac86487..a281d59b 100644 --- a/src/Backends/Plex/PlexGuid.php +++ b/src/Backends/Plex/PlexGuid.php @@ -191,9 +191,16 @@ final class PlexGuid implements iGuid } catch (Throwable $e) { if (true === $log) { $this->logger->error( - 'Unhandled exception was thrown in parsing of [{backend}] [{agent}] identifier.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing [{agent}] identifier. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $this->context->backendName, + 'client' => $this->context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'agent' => $val, 'exception' => [ 'file' => $e->getFile(), @@ -292,9 +299,16 @@ final class PlexGuid implements iGuid } catch (Throwable $e) { if (true === $log) { $this->logger->error( - 'Unhandled exception was thrown in parsing of [{backend}] legacy agent [{agent}] identifier.', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{client}: {backend}] parsing legacy agent [{agent}] identifier. Error [{error.message} @ {error.file}:{error.line}].', + context: [ 'backend' => $this->context->backendName, + 'client' => $this->context->clientName, + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], 'agent' => $guid, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Commands/Backend/RestoreCommand.php b/src/Commands/Backend/RestoreCommand.php index e0ac8c6b..ad6864b3 100644 --- a/src/Commands/Backend/RestoreCommand.php +++ b/src/Commands/Backend/RestoreCommand.php @@ -272,8 +272,8 @@ class RestoreCommand extends Command $this->logger->notice('Marked [{backend}] [{item.title}] as [{play_state}].', $context); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception thrown during request to change play state of [{backend}] {item.type} [{item.title}].', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{backend}] restore play state of {item.type} [{item.title}]. Error [{error.message} @ {error.file}:{error.line}].', + context: [ ...$context, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Commands/State/ExportCommand.php b/src/Commands/State/ExportCommand.php index 7288b3f2..260e5d6c 100644 --- a/src/Commands/State/ExportCommand.php +++ b/src/Commands/State/ExportCommand.php @@ -397,8 +397,14 @@ class ExportCommand extends Command $this->logger->notice('Marked [{backend}] [{item.title}] as [{play_state}].', $context); } catch (Throwable $e) { $this->logger->error( - 'Unhandled exception thrown during request to change play state of [{backend}] {item.type} [{item.title}].', - [ + message: 'Exception [{error.kind}] was thrown unhandled during [{backend}] request to change play state of {item.type} [{item.title}]. Error [{error.message} @ {error.file}:{error.line}].', + context: [ + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$context, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Commands/State/ProgressCommand.php b/src/Commands/State/ProgressCommand.php index 0b865e09..bebf4903 100644 --- a/src/Commands/State/ProgressCommand.php +++ b/src/Commands/State/ProgressCommand.php @@ -221,8 +221,14 @@ class ProgressCommand extends Command ]); } catch (\Throwable $e) { $this->logger->error( - 'SYSTEM: Unhandled exception thrown during request to change watch progress of [{backend}] {item.type} [{item.title}].', - [ + message: 'SYSTEM: Exception [{error.kind}] was thrown unhandled during [{backend}] request to change watch progress of {item.type} [{item.title}]. Error [{error.message} @ {error.file}:{error.line}].', + context: [ + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$context, 'exception' => [ 'file' => $e->getFile(), diff --git a/src/Commands/State/PushCommand.php b/src/Commands/State/PushCommand.php index 1ea7c044..25a78200 100644 --- a/src/Commands/State/PushCommand.php +++ b/src/Commands/State/PushCommand.php @@ -199,8 +199,14 @@ class PushCommand extends Command $this->logger->notice('SYSTEM: Marked [{backend}] [{item.title}] as [{play_state}].', $context); } catch (\Throwable $e) { $this->logger->error( - 'SYSTEM: Unhandled exception thrown during request to change play state of [{backend}] {item.type} [{item.title}].', - [ + message: 'SYSTEM: Exception [{error.kind}] was thrown unhandled during [{backend}] request to change play state of {item.type} [{item.title}]. Error [{error.message} @ {error.file}:{error.line}].', + context: [ + 'error' => [ + 'kind' => $e::class, + 'line' => $e->getLine(), + 'message' => $e->getMessage(), + 'file' => after($e->getFile(), ROOT_PATH), + ], ...$context, 'exception' => [ 'file' => $e->getFile(),