api: human friendly error for TLS [GH-123]

This commit is contained in:
Mitchell Hashimoto 2015-05-02 13:08:35 -07:00
parent c3a793ccdf
commit d4155ef9d8
2 changed files with 12 additions and 2 deletions

View File

@ -3,6 +3,8 @@
IMPROVEMENTS:
* core: Very verbose error if mlock fails [GH-59]
* command/*: On error with TLS oversized record, show more human-friendly
error message. [GH-123]
* command/server: Add configuration option to disable mlock
* command/server: Disable mlock for dev mode so it works on more systems

View File

@ -7,6 +7,7 @@ import (
"net/http/cookiejar"
"net/url"
"os"
"strings"
"time"
)
@ -170,9 +171,16 @@ START:
result = &Response{Response: resp}
}
if err != nil {
urlErr, ok := err.(*url.Error)
if ok && urlErr.Err == errRedirect {
if urlErr, ok := err.(*url.Error); ok && urlErr.Err == errRedirect {
err = nil
} else if strings.Contains(err.Error(), "tls: oversized") {
err = fmt.Errorf(
"%s\n\n"+
"This error usually means that the server is running with TLS disabled\n"+
"but the client is configured to use TLS. Please either enable TLS\n"+
"on the server, or run the client with -addr set to http://<addr>\n"+
"where <addr> is replaced by the actual address to the server.",
err)
}
}
if err != nil {