mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
Make ErrorStorage a concrete type not an interface
Since it is used in a type assertion, having it as an alias to the error interface is the same as saying 'error', i.e. it succeeds for all types of error. Change to a struct which is a concrete type and the type assertion will only succeed if the type is identical. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
f033f48f74
commit
9a956872a3
|
@ -74,7 +74,7 @@ type (
|
|||
ErrTooManySamples string
|
||||
// ErrStorage is returned if an error was encountered in the storage layer
|
||||
// during query handling.
|
||||
ErrStorage error
|
||||
ErrStorage struct{ error }
|
||||
)
|
||||
|
||||
func (e ErrQueryTimeout) Error() string {
|
||||
|
@ -86,6 +86,9 @@ func (e ErrQueryCanceled) Error() string {
|
|||
func (e ErrTooManySamples) Error() string {
|
||||
return fmt.Sprintf("query processing would load too many samples into memory in %s", string(e))
|
||||
}
|
||||
func (e ErrStorage) Error() string {
|
||||
return e.error.Error()
|
||||
}
|
||||
|
||||
// A Query is derived from an a raw query string and can be run against an engine
|
||||
// it is associated with.
|
||||
|
|
|
@ -193,7 +193,7 @@ func TestQueryError(t *testing.T) {
|
|||
Timeout: 10 * time.Second,
|
||||
}
|
||||
engine := NewEngine(opts)
|
||||
errStorage := ErrStorage(fmt.Errorf("storage error"))
|
||||
errStorage := ErrStorage{fmt.Errorf("storage error")}
|
||||
queryable := storage.QueryableFunc(func(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
|
||||
return &errQuerier{err: errStorage}, nil
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue