Skip to content

Commit

Permalink
changed error message generation according to linter suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bizk committed Sep 20, 2023
1 parent 3b55e48 commit 75f034a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rosetta

import (
"errors"
"fmt"
"os"
"plugin"
Expand All @@ -13,24 +12,24 @@ func LoadPlugin(ir codectypes.InterfaceRegistry, pluginLocation string) (err err
pluginPathMain := fmt.Sprintf("./plugins/%s/main.so", pluginLocation)

if _, err := os.Stat(pluginPathMain); os.IsExist(err) {
return errors.New(fmt.Sprintf("Plugin file '%s' does not exist %s", pluginPathMain, err.Error()))
return fmt.Errorf(fmt.Sprintf("Plugin file '%s' does not exist %s", pluginPathMain, err.Error()))
}

// load module
plug, err := plugin.Open(pluginPathMain)
if err != nil {
return errors.New(fmt.Sprintf("There was an error while opening plugin on %s - %s", pluginPathMain, err.Error()))
return fmt.Errorf(fmt.Sprintf("There was an error while opening plugin on %s - %s", pluginPathMain, err.Error()))
}

initZone, err := plug.Lookup("InitZone")
if err != nil {
return errors.New(fmt.Sprintf("There was an error while initializing the zone %s", err.Error()))
return fmt.Errorf(fmt.Sprintf("There was an error while initializing the zone %s", err.Error()))
}
initZone.(func())()

registerInterfaces, err := plug.Lookup("RegisterInterfaces")
if err != nil {
return errors.New(fmt.Sprintf("There was an error while registering interfaces %s", err.Error()))
return fmt.Errorf(fmt.Sprintf("There was an error while registering interfaces %s", err.Error()))
}

registerInterfaces.(func(codectypes.InterfaceRegistry))(ir)
Expand Down

0 comments on commit 75f034a

Please sign in to comment.