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

[gui][c] Improve error messages

parent f20e3606
Pipeline #405 passed with stage
......@@ -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)
}
......@@ -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())
}
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, errors.New(grpc.ErrorDesc(err))
}
return response, nil
......
......@@ -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, errors.New(grpc.ErrorDesc(err))
}
return response, nil
......
......@@ -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">
......
......@@ -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)
})
}
......@@ -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">
......
Markdown is supported
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