summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/keybase/go-keybase-chat-bot/kbchat/errors.go
blob: 1d1e6315bc5200f35b86d1bbd9798e3bcad2d2aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package kbchat

import (
	"errors"
	"fmt"
)

type ErrorCode int

var errAPIDisconnected = errors.New("chat API disconnected")

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)
}