2020-02-08 16:50:16 +01:00
|
|
|
package kbchat
|
|
|
|
|
2020-05-24 00:06:21 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
2020-02-08 16:50:16 +01:00
|
|
|
|
|
|
|
type ErrorCode int
|
|
|
|
|
2020-05-24 00:06:21 +02:00
|
|
|
var errAPIDisconnected = errors.New("chat API disconnected")
|
|
|
|
|
2020-02-08 16:50:16 +01:00
|
|
|
const (
|
|
|
|
RevisionErrorCode ErrorCode = 2760
|
|
|
|
DeleteNonExistentErrorCode ErrorCode = 2762
|
|
|
|
)
|
|
|
|
|
|
|
|
// Error is for unmarshaling CLI json responses
|
|
|
|
type Error struct {
|
|
|
|
Code ErrorCode `json:"code"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e Error) Error() string {
|
|
|
|
return fmt.Sprintf("received error response from keybase api: %s", e.Message)
|
|
|
|
}
|
|
|
|
|
|
|
|
type APIError struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e APIError) Error() string {
|
|
|
|
return fmt.Sprintf("failed to call keybase api: %v", e.err)
|
|
|
|
}
|
|
|
|
|
|
|
|
type UnmarshalError struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e UnmarshalError) Error() string {
|
|
|
|
return fmt.Sprintf("failed to parse output from keybase api: %v", e.err)
|
|
|
|
}
|