Skip to content

Commit

Permalink
33579 - Slightly more helpful error message upon validation error dur…
Browse files Browse the repository at this point in the history
…ing import
  • Loading branch information
derjoachim committed Dec 23, 2024
1 parent a8c8f84 commit aa3b844
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- Tasks: fix several bugs in ICS import
- OAuth2 client: return more informative exception if a session variable is missing.
- Core: Slightly more helpful debug data upon validation errors import

12-12-2024: 6.8.90
- Core: Show database error on upgrade
Expand Down
11 changes: 8 additions & 3 deletions www/go/core/data/convert/AbstractConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ private function notifyCount(int $count, int $errorCount) {
}

private function notifyError(string $error) {
// JH20241223: TODO? This alert is overwritten immediately. Would it not make sense to make an alert for each faild import...
// ...so instead of using $this->>alert just create its own alert?
$this->alert = new Alert();


Expand Down Expand Up @@ -278,10 +280,13 @@ public final function importFile(File $file, array $params = array()): array
EntityType::push(100);

if($entity->hasValidationErrors()) {
$msg = "Item ". $this->index . ": ". var_export($entity->getValidationErrors(), true);
$this->notifyError($msg);
foreach ($entity->getValidationErrors() as $key => $validationError) {
$msg = "Validation error in item " . $this->index . ": " . $key . " - " . $validationError['description'];
$this->notifyError($msg);

$response['errors'][] = $msg;
$response['errors'][] = $msg;

}
} elseif($this->afterSave($entity)) {
$response['count']++;
} else{
Expand Down

0 comments on commit aa3b844

Please sign in to comment.