changeset 3681:c9e1848a516a

Handle violation of responsibility areas graceful for BN import. As many others this is an error, which should only affect the specific bottleneck failing and not the whole import.
author Sascha Wilde <wilde@intevation.de>
date Tue, 18 Jun 2019 12:43:01 +0200
parents 0300282b9537
children c086f5176ef2
files pkg/imports/bn.go pkg/imports/errors.go
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/bn.go	Tue Jun 18 12:02:18 2019 +0200
+++ b/pkg/imports/bn.go	Tue Jun 18 12:43:01 2019 +0200
@@ -425,7 +425,8 @@
 		bnIds = append(bnIds, nid)
 	}
 	if err := bns.Err(); err != nil {
-		return err
+		feedback.Warn(handleError(err).Error())
+		return nil
 	}
 	if len(bnIds) == 0 {
 		feedback.Warn(
--- a/pkg/imports/errors.go	Tue Jun 18 12:02:18 2019 +0200
+++ b/pkg/imports/errors.go	Tue Jun 18 12:43:01 2019 +0200
@@ -29,9 +29,10 @@
 
 // Handle PostgreSQL error codes
 const (
-	notNullViolation    = "23502"
-	foreignKeyViolation = "23503"
-	noDataFound         = "P0002"
+	notNullViolation         = "23502"
+	foreignKeyViolation      = "23503"
+	violatesRowLevelSecurity = "42501"
+	noDataFound              = "P0002"
 )
 
 type dbError pgx.PgError
@@ -75,6 +76,9 @@
 		case strings.Contains(recent, "isrsrange_area"):
 			return "No area around axis between given ISRS Location Codes"
 		}
+
+	case violatesRowLevelSecurity:
+		return "Could not save: Data outside the area of responsibility."
 	}
 	return "Unexpected database error: " + err.Message
 }