From 069b3526099bf309e9a0e5a0e9d4fc07a6ecef53 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 10 Sep 2024 16:34:59 +0200 Subject: Fix polygon validation --- src/graphql/types/alert.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/graphql/types/alert.rs b/src/graphql/types/alert.rs index ba93c03..2e7f10b 100644 --- a/src/graphql/types/alert.rs +++ b/src/graphql/types/alert.rs @@ -216,7 +216,15 @@ pub mod mutations { let polygon = format!("ST_MakePolygon(ST_MakeLine(ARRAY[{}]))", points); let valid_query = format!("SELECT ST_IsValid({}) as is_valid", polygon); - let rows = client.query(&valid_query, &[]).await.unwrap(); + let rows; + match client.query(&valid_query, &[]).await { + Ok(r) => { + rows = r; + } + Err(_) => { + return Err(async_graphql::Error::new("Polygon is not valid")); + } + }; let is_valid: bool = rows[0].get("is_valid"); if !is_valid { -- cgit v1.2.3-18-g5258