Commit ab8cd887 authored by Loïck Bonniot's avatar Loïck Bonniot
Browse files

[gui][c] Improve error messages

parent f20e3606
Pipeline #405 passed with stage
...@@ -21,5 +21,5 @@ func EvaluateErrorCodeResponse(code *api.ErrorCode) error { ...@@ -21,5 +21,5 @@ func EvaluateErrorCodeResponse(code *api.ErrorCode) error {
if len(code.Message) == 0 { if len(code.Message) == 0 {
return errors.New("Received error code " + (code.Code).String()) 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)
} }
...@@ -46,5 +46,5 @@ func TestEvaluateErrorCodeResponse(t *testing.T) { ...@@ -46,5 +46,5 @@ func TestEvaluateErrorCodeResponse(t *testing.T) {
} }
err = EvaluateErrorCodeResponse(otherWithMessage) err = EvaluateErrorCodeResponse(otherWithMessage)
assert.Equal(t, "Received error code INVARG: Invalid mail", err.Error()) assert.Equal(t, "Invalid mail", err.Error())
} }
package user package user
import ( import (
"dfss/dfssc/common"
"dfss/dfssc/security"
pb "dfss/dfssp/api"
"errors"
"io/ioutil" "io/ioutil"
"regexp" "regexp"
"time" "time"
"dfss/dfssc/common"
"dfss/dfssc/security"
pb "dfss/dfssp/api"
"errors"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc"
) )
// AuthManager handles the authentication of a user // AuthManager handles the authentication of a user
...@@ -102,11 +103,11 @@ func (m *AuthManager) sendRequest() (*pb.RegisteredUser, error) { ...@@ -102,11 +103,11 @@ func (m *AuthManager) sendRequest() (*pb.RegisteredUser, error) {
} }
// Stop the context if it takes too long for the platform to answer // 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() defer cancel()
response, err := client.Auth(ctx, request) response, err := client.Auth(ctx, request)
if err != nil { if err != nil {
return nil, err return nil, errors.New(grpc.ErrorDesc(err))
} }
return response, nil return response, nil
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"dfss/dfssc/security" "dfss/dfssc/security"
pb "dfss/dfssp/api" pb "dfss/dfssp/api"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc"
) )
// RegisterManager handles the registration of a user // RegisterManager handles the registration of a user
...@@ -153,7 +154,7 @@ func (m *RegisterManager) sendRequest(certRequest string) (*pb.ErrorCode, error) ...@@ -153,7 +154,7 @@ func (m *RegisterManager) sendRequest(certRequest string) (*pb.ErrorCode, error)
defer cancel() defer cancel()
response, err := client.Register(ctx, request) response, err := client.Register(ctx, request)
if err != nil { if err != nil {
return nil, err return nil, errors.New(grpc.ErrorDesc(err))
} }
return response, nil return response, nil
......
...@@ -81,13 +81,26 @@ ...@@ -81,13 +81,26 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <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>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QPushButton" name="authButton"> <widget class="QPushButton" name="authButton">
<property name="text"> <property name="text">
<string>Authenticate</string> <string>Authenticate</string>
</property> </property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
......
...@@ -46,5 +46,8 @@ func main() { ...@@ -46,5 +46,8 @@ func main() {
w.SetWindowTitle("DFSS Client v" + dfss.Version) w.SetWindowTitle("DFSS Client v" + dfss.Version)
w.SetFixedSizeWithWidthHeight(WIDTH, HEIGHT) w.SetFixedSizeWithWidthHeight(WIDTH, HEIGHT)
w.Show() w.Show()
ev := ui.NewCloseEvent()
w.CloseEvent(ev)
}) })
} }
...@@ -152,6 +152,12 @@ ...@@ -152,6 +152,12 @@
<property name="text"> <property name="text">
<string>Register</string> <string>Register</string>
</property> </property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment