Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
c5e5502b
Commit
c5e5502b
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Update user errors map
parent
946e42b8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!23
Release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/errors.go
+18
-4
18 additions, 4 deletions
bindings/errors.go
with
18 additions
and
4 deletions
bindings/errors.go
+
18
−
4
View file @
c5e5502b
...
@@ -17,6 +17,21 @@ import (
...
@@ -17,6 +17,21 @@ import (
// (Back-end) "Building new HostPool because no HostList stored:": (Front-end) "Missing host list",
// (Back-end) "Building new HostPool because no HostList stored:": (Front-end) "Missing host list",
var
ErrToUserErr
=
map
[
string
]
string
{
var
ErrToUserErr
=
map
[
string
]
string
{
// todo populate with common errors
// todo populate with common errors
// Registration errors
"cannot create username when network is not health"
:
"Cannot create username, unable to connect to network"
,
"failed to add due to malformed fact stringified facts must at least have a type at the start"
:
"Invalid fact, is the field empty?"
,
// UD failures
"failed to create user discovery manager: cannot return single manager, network is not health"
:
"Could not connect to user discovery"
,
"user discovery returned error on search: no results found"
:
"No results found"
,
"failed to search.: waiting for response to single-use transmisson timed out after 10s"
:
"Search timed out"
,
"the phone number supplied was empty"
:
"Invalid phone number"
,
"failed to create user discovery manager: cannot start ud manager when network follower is not running."
:
"Could not get network status"
,
}
}
// Error codes
// Error codes
...
@@ -34,8 +49,7 @@ func ErrorStringToUserFriendlyMessage(errStr string) string {
...
@@ -34,8 +49,7 @@ func ErrorStringToUserFriendlyMessage(errStr string) string {
// Go through common errors
// Go through common errors
for
backendErr
,
userFriendly
:=
range
ErrToUserErr
{
for
backendErr
,
userFriendly
:=
range
ErrToUserErr
{
// Determine if error contains a common error
// Determine if error contains a common error
// Fixme: later versions may be improved by using regex
if
strings
.
Contains
(
errStr
,
backendErr
)
{
if
strings
.
HasPrefix
(
errStr
,
backendErr
)
{
return
userFriendly
return
userFriendly
}
}
}
}
...
@@ -47,14 +61,14 @@ func ErrorStringToUserFriendlyMessage(errStr string) string {
...
@@ -47,14 +61,14 @@ func ErrorStringToUserFriendlyMessage(errStr string) string {
// as context deadline exceeded is not informative
// as context deadline exceeded is not informative
rpcErr
:=
"rpc "
rpcErr
:=
"rpc "
rpcIdx
:=
strings
.
Index
(
errStr
,
rpcErr
)
rpcIdx
:=
strings
.
Index
(
errStr
,
rpcErr
)
return
UnrecognizedCode
+
errStr
[
:
rpcIdx
]
return
errStr
[
:
rpcIdx
]
}
else
if
strings
.
Contains
(
errStr
,
descStr
)
{
}
else
if
strings
.
Contains
(
errStr
,
descStr
)
{
// If containing an rpc error where context deadline exceeded
// If containing an rpc error where context deadline exceeded
// is NOT involved, the error returned server-side is often
// is NOT involved, the error returned server-side is often
//more informative
//more informative
descIdx
:=
strings
.
Index
(
errStr
,
descStr
)
descIdx
:=
strings
.
Index
(
errStr
,
descStr
)
// return everything after "desc = "
// return everything after "desc = "
return
UnrecognizedCode
+
errStr
[
descIdx
+
len
(
descStr
)
:
]
return
errStr
[
descIdx
+
len
(
descStr
)
:
]
}
}
// If a compound error message, return the highest level message
// If a compound error message, return the highest level message
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment