mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
add a try catch around template validation
This commit is contained in:
parent
ce7a8ad808
commit
f4e69679ca
|
@ -38,7 +38,6 @@ class Label implements View
|
|||
$settings = $this->data->get('settings');
|
||||
$assets = $this->data->get('assets');
|
||||
$offset = $this->data->get('offset');
|
||||
$template = LabelModel::find($settings->label2_template);
|
||||
|
||||
// If disabled, pass to legacy view
|
||||
if ((!$settings->label2_enable)) {
|
||||
|
@ -49,11 +48,24 @@ class Label implements View
|
|||
->with('count', $this->data->get('count'));
|
||||
}
|
||||
|
||||
if ($template === null) {
|
||||
throw new \UnexpectedValueException('Template is null.');
|
||||
try {
|
||||
$template = LabelModel::find($settings->label2_template);
|
||||
|
||||
if ($template === null) {
|
||||
throw new \UnexpectedValueException('Template is null.');
|
||||
}
|
||||
|
||||
$template->validate();
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
|
||||
\Log::error('Validation failed: ' . $e->getMessage());
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
\Log::error('An unexpected error occurred: ' . $e->getMessage());
|
||||
|
||||
}
|
||||
|
||||
$template->validate();
|
||||
|
||||
$pdf = new TCPDF(
|
||||
$template->getOrientation(),
|
||||
|
|
Loading…
Reference in a new issue