mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-17 23:17:09 -04:00
go-micro errors on bundles (OCIS-363)
This commit is contained in:
committed by
Benedikt Kulmann
parent
dedcbd0412
commit
5f07c992da
@@ -23,7 +23,7 @@ func (s Store) ListBundles(bundleType proto.Bundle_Type) ([]*proto.Bundle, error
|
||||
bundlesFolder := s.buildFolderPathForBundles(false)
|
||||
bundleFiles, err := ioutil.ReadDir(bundlesFolder)
|
||||
if err != nil {
|
||||
return []*proto.Bundle{}, nil
|
||||
return []*proto.Bundle{}, merrors.FromError(err)
|
||||
}
|
||||
|
||||
records := make([]*proto.Bundle, 0, len(bundleFiles))
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/golang/protobuf/jsonpb"
|
||||
"github.com/golang/protobuf/proto"
|
||||
merrors "github.com/micro/go-micro/v2/errors"
|
||||
)
|
||||
|
||||
// Unmarshal file into record
|
||||
@@ -12,7 +13,7 @@ func (s Store) parseRecordFromFile(record proto.Message, filePath string) error
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error reading file %v: file not found", filePath)
|
||||
return err
|
||||
return merrors.FromError(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
@@ -29,14 +30,14 @@ func (s Store) writeRecordToFile(record proto.Message, filePath string) error {
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
s.Logger.Err(err).Msgf("error writing file %v: opening failed", filePath)
|
||||
return err
|
||||
return merrors.FromError(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
encoder := jsonpb.Marshaler{}
|
||||
if err = encoder.Marshal(file, record); err != nil {
|
||||
s.Logger.Err(err).Msgf("error writing file %v: marshalling failed", filePath)
|
||||
return err
|
||||
return merrors.FromError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user