Log errors only if debugging is enabled

This commit is contained in:
DariusIII
2019-01-30 15:34:47 +01:00
parent 96fe6c27c3
commit 04e8b17559
4 changed files with 43 additions and 14 deletions
@@ -1643,7 +1643,9 @@ class ProcessAdditional
return $files;
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
$this->_debug('ERROR: Could not open temp dir: '.$e->getMessage());
return false;
@@ -1780,7 +1782,9 @@ class ProcessAdditional
$audioSample->clip(TimeCode::fromSeconds(30), TimeCode::fromSeconds(30));
$audioSample->save($format, $this->tmpPath.$audioFileName);
} catch (\InvalidArgumentException $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}
@@ -1897,13 +1901,19 @@ class ProcessAdditional
try {
$this->ffmpeg->open($fileLocation)->frame(TimeCode::fromString($time === '' ? '00:00:03:00' : $time))->save($fileName);
} catch (\RuntimeException $runtimeException) {
Log::error($runtimeException->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($runtimeException->getTraceAsString());
}
//We show no error we just log it, we failed to save the frame and move on
} catch (\InvalidArgumentException $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
} catch (\Throwable $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
//Again we do nothing, we just want to catch the error
}
}
@@ -1995,7 +2005,9 @@ class ProcessAdditional
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
} catch (\InvalidArgumentException $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}
@@ -2013,7 +2025,9 @@ class ProcessAdditional
$videoSample->filters()->resize(new Dimension(320, -1), ResizeFilter::RESIZEMODE_SCALE_HEIGHT);
$videoSample->save($format, $fileName);
} catch (\InvalidArgumentException $e) {
Log::error($e->getTraceAsString());
if (config('app.debug' === true)) {
Log::error($e->getTraceAsString());
}
//We do nothing, just prevent displaying errors because the file cannot be open(corrupted or incomplete file)
}
}