aboutsummaryrefslogtreecommitdiff
path: root/pkg/monitor/errors.go
blob: 4d676af542eebfadc90d546090b6b176ee85a48e (plain)
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 monitor

import (
	"fmt"

	ct "github.com/google/certificate-transparency-go"
)

// ErrorFetch occurs if there's a problem hitting the log's HTTP API.  An STH is
// provided if available, since it might carry evidence of some log misbehavior.
type ErrorFetch struct {
	URL string
	Msg string
	Err error
	STH *ct.SignedTreeHead
}

func (e ErrorFetch) Error() string {
	return fmt.Sprintf("%s: %s: %v", e.URL, e.Msg, e.Err)
}

// ErrorMerkleTree occurs if the log's Merkle tree can't be verified.  An STH is
// provided if available (i.e., won't be available for internal tree building).
type ErrorMerkleTree struct {
	URL string
	Msg string
	Err error
	STH *ct.SignedTreeHead
}

func (e ErrorMerkleTree) Error() string {
	return fmt.Sprintf("%s: %s: %v", e.URL, e.Msg, e.Err)
}

// TODO: MMD violations
// TODO: Growing read-only logs

// noout implements the Logger interface to discard unwanted output
type noout struct{}

func (n *noout) Printf(string, ...interface{}) {}