Skip to content

Commit

Permalink
add recover
Browse files Browse the repository at this point in the history
  • Loading branch information
sters committed Oct 29, 2021
1 parent 66553b0 commit b22c0bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion onstatic/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,17 @@ func checkLastModTime(pluginFsInfo os.FileInfo, repoName string) error {

var loadPlugin = loadPluginActual // for testing

func loadPluginActual(repoFs billy.Filesystem, filename string) (oplugin.EntryPoint, error) {
func loadPluginActual(repoFs billy.Filesystem, filename string) (ep oplugin.EntryPoint, reterr error) {
path := repoFs.Join(repoFs.Root(), oplugin.PluginDir, filename)

defer func() {
if err := recover(); err != nil {
reterr = failure.Unexpected(
fmt.Sprintf("%+v", err),
failure.Messagef("failed to load plugin: cannot open plugin: %s", path),
)
}
}()
p, err := plugin.Open(path)
if err != nil {
return nil, failure.Wrap(err, failure.Messagef("failed to load plugin: cannot open plugin: %s", path))
Expand Down

0 comments on commit b22c0bd

Please sign in to comment.