Skip to content

Commit

Permalink
[TM-1531] fix error output
Browse files Browse the repository at this point in the history
  • Loading branch information
egrojMonroy committed Dec 19, 2024
1 parent a72ba66 commit 039e9be
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/Services/PolygonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,22 +547,26 @@ public function insertGeojsonToDBFromContent(string $geojsonData, ?string $entit
$geojson = json_decode($geojsonData, true);
SitePolygonValidator::validate('FEATURE_BOUNDS', $geojson, false);
SitePolygonValidator::validate('GEOMETRY_TYPE', $geojson, false);

return $this->createGeojsonModels($geojson, ['site_id' => $entity_uuid, 'source' => PolygonService::UPLOADED_SOURCE], $primary_uuid, $submit_polygon_loaded);

} catch (Exception $e) {
$errorMessage = $e->getMessage();
$decodedErrorMessage = json_decode($errorMessage, true);
$decodedError = json_decode($errorMessage, true);

if (json_last_error() === JSON_ERROR_NONE) {
return ['error' => $decodedErrorMessage];
Log::error('Validation error', ['error' => $decodedError]);
return [
'error' => json_encode($decodedError)
];
} else {
Log::info('Error inserting geojson to DB', ['error' => $errorMessage]);

return ['error' => $errorMessage];
Log::error('Validation error', ['error' => $errorMessage]);
return [
'error' => $errorMessage
];
}
}
}

public function processClippedPolygons(array $polygonUuids, $delayed_job_id = null)
{
$geojson = GeometryHelper::getPolygonsGeojson($polygonUuids);
Expand Down

0 comments on commit 039e9be

Please sign in to comment.