diff --git a/app/model/entity/AsyncJob.php b/app/model/entity/AsyncJob.php index ec29d4319..c86743773 100644 --- a/app/model/entity/AsyncJob.php +++ b/app/model/entity/AsyncJob.php @@ -211,9 +211,21 @@ public function getError(): ?string return $this->error; } + /** + * Makes sure the error string fits the data column. + * Truncates and adds ellipsis '...' at the end if it overflows. + */ + private function sanitizeErrorLength(): void + { + if ($this->error !== null && strlen($this->error) > 250) { + $this->error = substr($this->error, 0, 250) . '...'; + } + } + public function setError(?string $error) { $this->error = $error; + $this->sanitizeErrorLength(); } public function appendError(string $error) @@ -223,6 +235,7 @@ public function appendError(string $error) } else { $this->error .= "\n$error"; } + $this->sanitizeErrorLength(); } /**