-
Notifications
You must be signed in to change notification settings - Fork 664
/
errors.go
31 lines (26 loc) · 951 Bytes
/
errors.go
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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package rpcchainvm
import (
"github.com/ava-labs/avalanchego/database"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block"
vmpb "github.com/ava-labs/avalanchego/proto/pb/vm"
)
var (
errEnumToError = map[vmpb.Error]error{
vmpb.Error_ERROR_CLOSED: database.ErrClosed,
vmpb.Error_ERROR_NOT_FOUND: database.ErrNotFound,
vmpb.Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED: block.ErrStateSyncableVMNotImplemented,
}
errorToErrEnum = map[error]vmpb.Error{
database.ErrClosed: vmpb.Error_ERROR_CLOSED,
database.ErrNotFound: vmpb.Error_ERROR_NOT_FOUND,
block.ErrStateSyncableVMNotImplemented: vmpb.Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED,
}
)
func errorToRPCError(err error) error {
if _, ok := errorToErrEnum[err]; ok {
return nil
}
return err
}