Improve data errors for twig

This commit is contained in:
David Bomba 2024-08-04 07:28:20 +10:00
parent b707671cd8
commit 620bd18cf9
4 changed files with 6 additions and 5 deletions

View File

@ -298,6 +298,9 @@ class PreviewController extends BaseController
->mock(); ->mock();
} catch(SyntaxError $e) { } catch(SyntaxError $e) {
} }
catch(\Exception $e) {
return response()->json(['message' => 'invalid data access', 'errors' => ['design.design.body' => $e->getMessage()]], 422);
}
if (request()->query('html') == 'true') { if (request()->query('html') == 'true') {
return $ts->getHtml(); return $ts->getHtml();

View File

@ -31,12 +31,8 @@ class TwigLint implements ValidationRule
try { try {
$twig->parse($twig->tokenize(new \Twig\Source(preg_replace('/<!--.*?-->/s', '', $value), ''))); $twig->parse($twig->tokenize(new \Twig\Source(preg_replace('/<!--.*?-->/s', '', $value), '')));
} catch (\Twig\Error\SyntaxError $e) { } catch (\Twig\Error\SyntaxError $e) {
// echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
nlog($e->getMessage());
$fail($e->getMessage()); $fail($e->getMessage());
} }
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -482,6 +482,8 @@ class TemplateService
default => $processed = [], default => $processed = [],
}; };
nlog(json_encode($processed));
return $processed; return $processed;
})->toArray(); })->toArray();