annotate pkg/pgxutils/errors.go @ 4181:bd97dc2dceea

Add readable error message for SR import
author Tom Gottfried <tom@intevation.de>
date Mon, 05 Aug 2019 18:32:54 +0200
parents 1fb3a62d8ea7
children 940b53bdf871
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 //
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 //
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2019 by via donau
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 //
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 // Author(s):
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 // * Tom Gottfried <tom.gottfried@intevation.de>
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
13 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15 package pgxutils
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 import (
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
18 "net/http"
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 "strings"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 "github.com/jackc/pgx"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 )
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24 const (
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 notNullViolation = "23502"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26 foreignKeyViolation = "23503"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 uniqueViolation = "23505"
4181
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
28 checkViolation = "23514"
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 violatesRowLevelSecurity = "42501"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 noDataFound = "P0002"
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 )
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32
4175
1fb3a62d8ea7 Made 'golint' and 'staticcheck' happy with pgxutils package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4132
diff changeset
33 // ReadableError wraps a given error Err and
1fb3a62d8ea7 Made 'golint' and 'staticcheck' happy with pgxutils package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4132
diff changeset
34 // permits extraction of more user-friendly
1fb3a62d8ea7 Made 'golint' and 'staticcheck' happy with pgxutils package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4132
diff changeset
35 // error messages from it in case it is an error
1fb3a62d8ea7 Made 'golint' and 'staticcheck' happy with pgxutils package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4132
diff changeset
36 // from the PostgreSQL backend.
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
37 type ReadableError struct {
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
38 Err error
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
39 }
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
40
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
41 func (re ReadableError) Error() string {
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
42 m, _ := re.MessageAndCode()
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
43 return m
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
44 }
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
46 // MessageAndCode returns a user-readable message
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
47 // and a matching HTTP status code.
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
48 // If its not a pgx.PgError it defaults to
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
49 // calling the parent Error method and returns its
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
50 // result together with http.StatusInternalServerError.
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
51 func (re ReadableError) MessageAndCode() (string, int) {
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
52 if e, ok := re.Err.(pgx.PgError); ok {
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
53 return messageAndCode(e)
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
54 }
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
55 return re.Err.Error(), http.StatusInternalServerError
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
56 }
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
57
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
58 func messageAndCode(err pgx.PgError) (m string, c int) {
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
59
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
60 c = http.StatusInternalServerError
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
61
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 switch err.Code {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 case notNullViolation:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
64 switch err.SchemaName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
65 case "waterway":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
66 switch err.TableName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
67 case "gauges":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
68 switch err.ColumnName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
69 case "objname":
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
70 m = "Missing objname"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
71 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72 case "geom":
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
73 m = "Missing lat/lon"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
74 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 case "zero_point":
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
76 m = "Missing zeropoint"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
77 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81 case foreignKeyViolation:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82 switch err.SchemaName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
83 case "waterway":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
84 switch err.TableName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 case "gauge_measurements", "gauge_predictions", "bottlenecks":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86 switch err.ConstraintName {
4132
ec8438712447 Enable better error handling for referenced gauges/bottlenecks constraints.
Sascha Wilde <wilde@intevation.de>
parents: 4071
diff changeset
87 case "gauge_key", "waterway_bottlenecks_reference_gauge":
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
88 m = "Referenced gauge with matching temporal validity not available"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
89 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
90 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93 case uniqueViolation:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 switch err.SchemaName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 case "internal":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 switch err.TableName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 case "user_profiles":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 switch err.ConstraintName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 case "user_profiles_pkey":
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
100 m = "A user with that name already exists"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
101 c = http.StatusConflict
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
102 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 }
4181
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
106 case checkViolation:
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
107 switch err.SchemaName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
108 case "waterway":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
109 switch err.TableName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
110 case "sounding_results":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
111 switch err.ConstraintName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
112 case "b_sounding_results_in_bn_area":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
113 m = "Dataset does not intersect with given bottleneck"
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
114 c = http.StatusConflict
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
115 return
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
116 }
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
117 }
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
118 }
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 case noDataFound:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120 // Most recent line from stacktrace contains name of failed function
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 recent := strings.SplitN(err.Where, "\n", 1)[0]
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 switch {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
123 case strings.Contains(recent, "isrsrange_points"):
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
124 m = "No distance mark found for at least one given ISRS Location Code"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
125 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 case strings.Contains(recent, "isrsrange_axis"):
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
127 m = "No contiguous axis found between given ISRS Location Codes"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
128 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129 case strings.Contains(recent, "isrsrange_area"):
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
130 m = "No area around axis between given ISRS Location Codes"
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
131 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133 case violatesRowLevelSecurity:
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
134 m = "Could not save: Data outside the area of responsibility."
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
135 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
136 }
4071
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
137 m = "Unexpected database error: " + err.Message
5867dcf8e93c Introduced a new ReadableError type for better readable error messages of pgx.PgErrors.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4063
diff changeset
138 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
139 }