mirror of
https://github.com/luxfi/node.git
synced 2026-07-27 03:39:39 +00:00
32 lines
868 B
Go
32 lines
868 B
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package rpcchainvm
|
|
|
|
import (
|
|
"github.com/luxfi/vm/chain"
|
|
"github.com/luxfi/database"
|
|
|
|
vmpb "github.com/luxfi/node/proto/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: chain.ErrRemoteVMNotImplemented,
|
|
}
|
|
errorToErrEnum = map[error]vmpb.Error{
|
|
database.ErrClosed: vmpb.Error_ERROR_CLOSED,
|
|
database.ErrNotFound: vmpb.Error_ERROR_NOT_FOUND,
|
|
chain.ErrRemoteVMNotImplemented: vmpb.Error_ERROR_STATE_SYNC_NOT_IMPLEMENTED,
|
|
}
|
|
)
|
|
|
|
func errorToRPCError(err error) error {
|
|
if _, ok := errorToErrEnum[err]; ok {
|
|
return nil
|
|
}
|
|
return err
|
|
}
|