Revert "Unmarshal SlackError as an error"
This reverts commit 2cfb1c0d1986ae8a8c4cfa37f316d29102e62de1.
Norberto Lopes
9 years ago
0 | 0 |
package slack
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"errors"
|
3 | 4 |
"net/url"
|
4 | 5 |
"strconv"
|
5 | 6 |
)
|
|
56 | 57 |
return nil, err
|
57 | 58 |
}
|
58 | 59 |
if !response.Ok {
|
59 | |
return nil, response.Error
|
|
60 |
return nil, errors.New(response.Error)
|
60 | 61 |
}
|
61 | 62 |
return response, nil
|
62 | 63 |
}
|
1 | 1 |
|
2 | 2 |
import (
|
3 | 3 |
"encoding/json"
|
|
4 |
"errors"
|
4 | 5 |
"net/url"
|
5 | 6 |
"strings"
|
6 | 7 |
)
|
|
84 | 85 |
return nil, err
|
85 | 86 |
}
|
86 | 87 |
if !response.Ok {
|
87 | |
return nil, response.Error
|
|
88 |
return nil, errors.New(response.Error)
|
88 | 89 |
}
|
89 | 90 |
return response, nil
|
90 | 91 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"errors"
|
3 | 4 |
"net/url"
|
4 | 5 |
"strconv"
|
5 | 6 |
)
|
|
34 | 35 |
return nil, err
|
35 | 36 |
}
|
36 | 37 |
if !response.Ok {
|
37 | |
return nil, response.Error
|
|
38 |
return nil, errors.New(response.Error)
|
38 | 39 |
}
|
39 | 40 |
return response, nil
|
40 | 41 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | |
import "net/url"
|
|
2 |
import (
|
|
3 |
"errors"
|
|
4 |
"net/url"
|
|
5 |
)
|
3 | 6 |
|
4 | 7 |
type emojiResponseFull struct {
|
5 | 8 |
Emoji map[string]string `json:"emoji"`
|
|
17 | 20 |
return nil, err
|
18 | 21 |
}
|
19 | 22 |
if !response.Ok {
|
20 | |
return nil, response.Error
|
|
23 |
return nil, errors.New(response.Error)
|
21 | 24 |
}
|
22 | 25 |
return response.Emoji, nil
|
23 | 26 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"errors"
|
3 | 4 |
"net/url"
|
4 | 5 |
"strconv"
|
5 | 6 |
)
|
|
48 | 49 |
return nil, err
|
49 | 50 |
}
|
50 | 51 |
if !response.Ok {
|
51 | |
return nil, response.Error
|
|
52 |
return nil, errors.New(response.Error)
|
52 | 53 |
}
|
53 | 54 |
return response, nil
|
54 | 55 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | |
import "net/url"
|
|
2 |
import (
|
|
3 |
"errors"
|
|
4 |
"net/url"
|
|
5 |
)
|
3 | 6 |
|
4 | 7 |
type oAuthResponseFull struct {
|
5 | 8 |
AccessToken string `json:"access_token"`
|
|
21 | 24 |
return "", "", err
|
22 | 25 |
}
|
23 | 26 |
if !response.Ok {
|
24 | |
return "", "", response.Error
|
|
27 |
return "", "", errors.New(response.Error)
|
25 | 28 |
}
|
26 | 29 |
return response.AccessToken, response.Scope, nil
|
27 | 30 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | |
import "net/url"
|
|
2 |
import (
|
|
3 |
"errors"
|
|
4 |
"net/url"
|
|
5 |
)
|
3 | 6 |
|
4 | 7 |
/*
|
5 | 8 |
Added as a var so that we can change this for testing purposes
|
|
18 | 21 |
}
|
19 | 22 |
|
20 | 23 |
type SlackResponse struct {
|
21 | |
Ok bool `json:"ok"`
|
22 | |
Error *SlackError `json:"error"`
|
23 | |
}
|
24 | |
|
25 | |
type SlackError struct {
|
26 | |
Code int
|
27 | |
Msg string
|
28 | |
}
|
29 | |
|
30 | |
func (s SlackError) Error() string {
|
31 | |
return s.Msg
|
|
24 |
Ok bool `json:"ok"`
|
|
25 |
Error string `json:"error"`
|
32 | 26 |
}
|
33 | 27 |
|
34 | 28 |
type AuthTestResponse struct {
|
|
68 | 62 |
return nil, err
|
69 | 63 |
}
|
70 | 64 |
if !responseFull.Ok {
|
71 | |
return nil, responseFull.Error
|
|
65 |
return nil, errors.New(responseFull.Error)
|
72 | 66 |
}
|
73 | 67 |
return &responseFull.AuthTestResponse, nil
|
74 | 68 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | 2 |
import (
|
|
3 |
"errors"
|
3 | 4 |
"net/url"
|
4 | 5 |
"strconv"
|
5 | 6 |
)
|
|
68 | 69 |
return nil, nil, err
|
69 | 70 |
}
|
70 | 71 |
if !response.Ok {
|
71 | |
return nil, nil, response.Error
|
|
72 |
return nil, nil, errors.New(response.Error)
|
72 | 73 |
}
|
73 | 74 |
return response.Items, &response.Paging, nil
|
74 | 75 |
}
|
0 | 0 |
package slack
|
1 | 1 |
|
2 | |
import "net/url"
|
|
2 |
import (
|
|
3 |
"errors"
|
|
4 |
"net/url"
|
|
5 |
)
|
3 | 6 |
|
4 | 7 |
// UserProfile contains all the information details of a given user
|
5 | 8 |
type UserProfile struct {
|
|
60 | 63 |
return nil, err
|
61 | 64 |
}
|
62 | 65 |
if !response.Ok {
|
63 | |
return nil, response.Error
|
|
66 |
return nil, errors.New(response.Error)
|
64 | 67 |
}
|
65 | 68 |
return response, nil
|
66 | 69 |
}
|
1 | 1 |
|
2 | 2 |
import (
|
3 | 3 |
"encoding/json"
|
|
4 |
"errors"
|
4 | 5 |
"fmt"
|
5 | 6 |
"io"
|
6 | 7 |
"log"
|
|
45 | 46 |
return nil, err
|
46 | 47 |
}
|
47 | 48 |
if !response.Ok {
|
48 | |
return nil, response.Error
|
|
49 |
return nil, errors.New(response.Error)
|
49 | 50 |
}
|
50 | 51 |
api.info = response.Info
|
51 | 52 |
// websocket.Dial does not accept url without the port (yet)
|