Skip to content

A self-hosted media server and file management system

fix: verify error stack trace is lost when a new error with just a custom message is thrown

aminnausind5934ba61303
diff --git a/app/Jobs/VerifyFiles.php b/app/Jobs/VerifyFiles.php
index 6cf7b34c..e2cdc30b 100755
--- a/app/Jobs/VerifyFiles.php
+++ b/app/Jobs/VerifyFiles.php
@@ -15,7 +15,6 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Bus;
-use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
@@ -321,15 +320,22 @@ class VerifyFiles implements ShouldQueue {
$this->taskService->updateSubTask($this->subTaskId, ['progress' => (int) (($index / count($this->videos)) * 100)]);
}
} catch (\Throwable $th) {
- $ids = array_map(function ($transaction) {
- return $transaction['id'];
- }, $transactions);
+ $ids = array_column($transactions, 'id');
$error = true;
- $errorMessage = 'cannot verify file metadata ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates and ' . count($this->videos) . ' checks with IDs ' . json_encode($ids);
- dump($errorMessage);
- throw new \Exception($errorMessage);
+ $message = sprintf(
+ 'Cannot verify file metadata: %s | Cancelling %d updates and %d checks with IDs: %s',
+ $th->getMessage(),
+ count($transactions),
+ count($this->videos),
+ json_encode($ids)
+ );
+
+ dump($message);
+ Log::error($message);
+
+ throw $th;
}
try {
@@ -371,12 +377,17 @@ class VerifyFiles implements ShouldQueue {
return $summary;
} catch (\Throwable $th) {
- $ids = array_map(function ($transaction) {
- return $transaction['id'];
- }, $transactions);
+ $ids = array_column($transactions, 'id');
- $errorMessage = 'Error cannot insert verified file metadata ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates with IDs ' . json_encode($ids); // . [...$ids]);
- dump($errorMessage);
+ $message = sprintf(
+ 'Error inserting verified file metadata: %s | Cancelling %d updates with IDs: %s',
+ $th->getMessage(),
+ count($transactions),
+ json_encode($ids)
+ );
+
+ dump($message);
+ Log::error($message);
throw $th;
}
@@ -499,13 +510,14 @@ class VerifyFiles implements ShouldQueue {
// If album art exists and the file was recently updated, overwrite the old image
$coverGenerated = $this->extractAlbumArt($filePath, $coverArtPath);
- if ($coverGenerated) {
- Storage::disk('public')->put($coverArtPath, $coverGenerated);
- return $this->getPathUrl($coverArtPath);
+ if (! $coverGenerated) {
+ return null;
}
- return null;
+ Storage::disk('public')->put($coverArtPath, $coverGenerated);
+
+ return $this->getPathUrl($coverArtPath);
}
private function extractAlbumArt($filePath, $outputPath): string|false {
diff --git a/app/Jobs/VerifyFolders.php b/app/Jobs/VerifyFolders.php
index f91aac40..aa0ca1ca 100644
--- a/app/Jobs/VerifyFolders.php
+++ b/app/Jobs/VerifyFolders.php
@@ -146,12 +146,19 @@ class VerifyFolders implements ShouldQueue {
$index += 1;
$this->taskService->updateSubTask($this->subTaskId, ['progress' => (int) (($index / count($this->folders)) * 100)]);
} catch (\Throwable $th) {
- $errorMessage = 'Error cannot verify folder series data ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates and ' . count($this->folders) . ' checks';
$error = true;
- dump($errorMessage);
+ $message = sprintf(
+ 'Error inserting verified folder series data: %s | Cancelling %d updates and %d checks',
+ $th->getMessage(),
+ count($transactions),
+ count($this->folders)
+ );
- throw new \Exception($errorMessage);
+ dump($message);
+ Log::error($message);
+
+ throw $th;
}
}
@@ -167,10 +174,19 @@ class VerifyFolders implements ShouldQueue {
return $summary;
} catch (\Throwable $th) {
- $errorMessage = 'Error cannot insert verified folder series data ' . $th->getMessage() . ' Cancelling ' . count($transactions) . ' updates'; // . [...$ids]);
- dump($errorMessage);
+ $ids = array_column($transactions, 'id');
+
+ $message = sprintf(
+ 'Error inserting verified folder series data: %s | Cancelling %d updates with IDs: %s',
+ $th->getMessage(),
+ count($transactions),
+ json_encode($ids)
+ );
- throw new \Exception($errorMessage);
+ dump($message);
+ Log::error($message);
+
+ throw $th;
}
}