Compare commits
11 commits
5857b091be
...
03beb6ab30
Author | SHA1 | Date | |
---|---|---|---|
03beb6ab30 | |||
3324cd7a4c | |||
ab415816af | |||
9a2e4724ec | |||
084814c6d1 | |||
56ea3f55c8 | |||
4911a7c464 | |||
25b7e64228 | |||
c1d1aa7759 | |||
124b4dc8e8 | |||
35666f39b7 |
4 changed files with 6 additions and 57 deletions
|
@ -14,7 +14,7 @@ Pre-built binaries will soon be available on the release page on both Codeberg a
|
|||
|
||||
### Build requirements
|
||||
|
||||
- **Go:** A minimum version of Go 1.22.5 is required for installing spruce.
|
||||
- **Go:** A minimum version of Go 1.22.0 is required for installing spruce.
|
||||
Please go [here](https://go.dev/dl/) to download the latest version.
|
||||
|
||||
- **Mage (Optional):** The project includes mage targets for building and installing the binary. The main
|
||||
|
|
2
go.mod
2
go.mod
|
@ -4,6 +4,6 @@
|
|||
|
||||
module codeflow.dananglin.me.uk/apollo/enbas
|
||||
|
||||
go 1.22.5
|
||||
go 1.22.0
|
||||
|
||||
require golang.org/x/net v0.26.0
|
||||
|
|
|
@ -123,25 +123,10 @@ func (g *Client) sendRequest(method string, url string, requestBody io.Reader, o
|
|||
defer response.Body.Close()
|
||||
|
||||
if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusBadRequest {
|
||||
message := struct {
|
||||
Error string `json:"error"`
|
||||
}{
|
||||
Error: "",
|
||||
}
|
||||
|
||||
if err := json.NewDecoder(response.Body).Decode(&message); err != nil {
|
||||
return ResponseError{
|
||||
StatusCode: response.StatusCode,
|
||||
Message: "",
|
||||
MessageDecodeErr: err,
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseError{
|
||||
StatusCode: response.StatusCode,
|
||||
Message: message.Error,
|
||||
MessageDecodeErr: nil,
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"did not receive an OK response from the GoToSocial server: got %d",
|
||||
response.StatusCode,
|
||||
)
|
||||
}
|
||||
|
||||
if object == nil {
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
// SPDX-FileCopyrightText: 2024 Dan Anglin <d.n.i.anglin@gmail.com>
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package client
|
||||
|
||||
import "fmt"
|
||||
|
||||
type ResponseError struct {
|
||||
StatusCode int
|
||||
Message string
|
||||
MessageDecodeErr error
|
||||
}
|
||||
|
||||
func (e ResponseError) Error() string {
|
||||
if e.MessageDecodeErr != nil {
|
||||
return fmt.Sprintf(
|
||||
"received HTTP code %d from the instance but was unable to decode the error message: %v",
|
||||
e.StatusCode,
|
||||
e.MessageDecodeErr,
|
||||
)
|
||||
}
|
||||
|
||||
if e.Message == "" {
|
||||
return fmt.Sprintf(
|
||||
"received HTTP code %d from the instance but no error message was provided",
|
||||
e.StatusCode,
|
||||
)
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"message received from the instance: (%d) %q",
|
||||
e.StatusCode,
|
||||
e.Message,
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue