Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpcs
dfss
Commits
ab8cd887
Commit
ab8cd887
authored
Mar 28, 2016
by
Loïck Bonniot
Browse files
[gui][c] Improve error messages
parent
f20e3606
Pipeline
#405
passed with stage
Changes
7
Pipelines
1
Show whitespace changes
Inline
Side-by-side
dfssc/common/errors.go
View file @
ab8cd887
...
...
@@ -21,5 +21,5 @@ func EvaluateErrorCodeResponse(code *api.ErrorCode) error {
if
len
(
code
.
Message
)
==
0
{
return
errors
.
New
(
"Received error code "
+
(
code
.
Code
)
.
String
())
}
return
errors
.
New
(
"Received error code "
+
(
code
.
Code
)
.
String
()
+
": "
+
code
.
Message
)
return
errors
.
New
(
code
.
Message
)
}
dfssc/common/errors_test.go
View file @
ab8cd887
...
...
@@ -46,5 +46,5 @@ func TestEvaluateErrorCodeResponse(t *testing.T) {
}
err
=
EvaluateErrorCodeResponse
(
otherWithMessage
)
assert
.
Equal
(
t
,
"
Received error code INVARG:
Invalid mail"
,
err
.
Error
())
assert
.
Equal
(
t
,
"Invalid mail"
,
err
.
Error
())
}
dfssc/user/authentication.go
View file @
ab8cd887
package
user
import
(
"dfss/dfssc/common"
"dfss/dfssc/security"
pb
"dfss/dfssp/api"
"errors"
"io/ioutil"
"regexp"
"time"
"dfss/dfssc/common"
"dfss/dfssc/security"
pb
"dfss/dfssp/api"
"errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
// AuthManager handles the authentication of a user
...
...
@@ -102,11 +103,11 @@ func (m *AuthManager) sendRequest() (*pb.RegisteredUser, error) {
}
// Stop the context if it takes too long for the platform to answer
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
TODO
(),
10
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
10
*
time
.
Second
)
defer
cancel
()
response
,
err
:=
client
.
Auth
(
ctx
,
request
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
ors
.
New
(
grpc
.
ErrorDesc
(
err
))
}
return
response
,
nil
...
...
dfssc/user/register.go
View file @
ab8cd887
...
...
@@ -9,6 +9,7 @@ import (
"dfss/dfssc/security"
pb
"dfss/dfssp/api"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
// RegisterManager handles the registration of a user
...
...
@@ -153,7 +154,7 @@ func (m *RegisterManager) sendRequest(certRequest string) (*pb.ErrorCode, error)
defer
cancel
()
response
,
err
:=
client
.
Register
(
ctx
,
request
)
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
ors
.
New
(
grpc
.
ErrorDesc
(
err
))
}
return
response
,
nil
...
...
gui/authform/authform.ui
View file @
ab8cd887
...
...
@@ -81,13 +81,26 @@
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"tokenField"
/>
<widget
class=
"QLineEdit"
name=
"tokenField"
>
<property
name=
"autoFillBackground"
>
<bool>
false
</bool>
</property>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QPushButton"
name=
"authButton"
>
<property
name=
"text"
>
<string>
Authenticate
</string>
</property>
<property
name=
"autoDefault"
>
<bool>
false
</bool>
</property>
<property
name=
"default"
>
<bool>
true
</bool>
</property>
<property
name=
"flat"
>
<bool>
false
</bool>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
...
...
gui/main.go
View file @
ab8cd887
...
...
@@ -46,5 +46,8 @@ func main() {
w
.
SetWindowTitle
(
"DFSS Client v"
+
dfss
.
Version
)
w
.
SetFixedSizeWithWidthHeight
(
WIDTH
,
HEIGHT
)
w
.
Show
()
ev
:=
ui
.
NewCloseEvent
()
w
.
CloseEvent
(
ev
)
})
}
gui/userform/userform.ui
View file @
ab8cd887
...
...
@@ -152,6 +152,12 @@
<property
name=
"text"
>
<string>
Register
</string>
</property>
<property
name=
"autoDefault"
>
<bool>
false
</bool>
</property>
<property
name=
"default"
>
<bool>
true
</bool>
</property>
</widget>
</item>
<item
row=
"3"
column=
"1"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment