capture error in CLI layer

This commit is contained in:
Trung Nguyen 2019-08-14 12:01:29 -04:00
parent d3c2c59b94
commit b4d7b1e282
No known key found for this signature in database
GPG Key ID: 4636434ED9505EB7
2 changed files with 9 additions and 7 deletions

View File

@ -345,7 +345,9 @@ func startNode(ctx *cli.Context, stack *node.Node) {
//initialize permission as we can create eth client only after the node and RPC are started
if stack.IsPermissionEnabled() {
permission.StartPermissionService(stack)
if err := permission.StartPermissionService(stack); err != nil {
utils.Fatalf("Unable to start Smart Contract based Permission Service due to %s", err)
}
}
// Start auxiliary services if enabled

View File

@ -12,7 +12,6 @@ import (
"sync"
"time"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/raft"
"github.com/ethereum/go-ethereum/rpc"
@ -143,22 +142,23 @@ func waitForSync(e *eth.Ethereum) {
}
}
func StartPermissionService(stack *node.Node) {
func StartPermissionService(stack *node.Node) error {
//initialize permission as we can create eth client only after the node and RPC are started
var permissionService *PermissionCtrl
if err := stack.Service(&permissionService); err != nil {
utils.Fatalf("cannot access permissions service %v", err)
return fmt.Errorf("cannot access permissions service %v", err)
}
if permissionService == nil {
utils.Fatalf("permission service unavailable")
return fmt.Errorf("permission service unavailable")
}
//initialize the service to create eth client and get ethereum service
if err := permissionService.InitializeService(); err != nil {
utils.Fatalf("permissions service initialization failed %v", err)
return fmt.Errorf("permissions service initialization failed %v", err)
}
if err := permissionService.Start(stack.Server()); err != nil {
utils.Fatalf("permissions service start failed %v", err)
return fmt.Errorf("permissions service start failed %v", err)
}
return nil
}
// Creates the controls structure for permissions