annotate pkg/pgxutils/errors.go @ 4664:7d2463c7b4ad

Added cmd/oct2str/oct2str to Makefile.
author Sascha Wilde <wilde@intevation.de>
date Mon, 14 Oct 2019 16:10:31 +0200
parents 49aa67fb2b6d
children 07e8436ef4de
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 {
4442
49aa67fb2b6d Improve error message if predictions reference no valid gauge
Tom Gottfried <tom@intevation.de>
parents: 4441
diff changeset
87 case "waterway_bottlenecks_reference_gauge",
49aa67fb2b6d Improve error message if predictions reference no valid gauge
Tom Gottfried <tom@intevation.de>
parents: 4441
diff changeset
88 "waterway_gauge_measurements_reference_gauge",
49aa67fb2b6d Improve error message if predictions reference no valid gauge
Tom Gottfried <tom@intevation.de>
parents: 4441
diff changeset
89 "waterway_gauge_predictions_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
90 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
91 return
4062
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 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 case uniqueViolation:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 switch err.SchemaName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 case "internal":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 switch err.TableName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 case "user_profiles":
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
100 switch err.ConstraintName {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
101 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
102 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
103 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
104 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 }
4181
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
108 case checkViolation:
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
109 switch err.SchemaName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
110 case "waterway":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
111 switch err.TableName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
112 case "sounding_results":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
113 switch err.ConstraintName {
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
114 case "b_sounding_results_in_bn_area":
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
115 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
116 c = http.StatusConflict
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
117 return
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
118 }
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
119 }
bd97dc2dceea Add readable error message for SR import
Tom Gottfried <tom@intevation.de>
parents: 4175
diff changeset
120 }
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 case noDataFound:
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 // 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
123 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
124 switch {
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 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
126 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
127 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128 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
129 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
130 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 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
132 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
133 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134 }
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135 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
136 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
137 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
138 }
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
139 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
140 return
4062
6c760abcff0e Move handling of PostgreSQL errors to own package
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
141 }