forked from TrueCloudLab/frostfs-node
[#521] Fix issues with transition from pkg/errors
pkg
Wrap functions at `pkg/errors` return nil if error argument was nil. fmt.Errorf always returns error so we need to add missing error checks to the code. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
71b87155ef
commit
b5256ccf4c
3 changed files with 14 additions and 6 deletions
|
@ -111,8 +111,10 @@ func bootstrapNode(c *cfg) {
|
|||
initState(c)
|
||||
|
||||
err := c.cfgNetmap.wrapper.AddPeer(c.toOnlineLocalNodeInfo())
|
||||
if err != nil {
|
||||
fatalOnErr(fmt.Errorf("bootstrap error: %w", err))
|
||||
}
|
||||
}
|
||||
|
||||
func addNetmapNotificationHandler(c *cfg, sTyp string, h event.Handler) {
|
||||
typ := event.TypeFromString(sTyp)
|
||||
|
@ -136,10 +138,14 @@ func setNetmapNotificationParser(c *cfg, sTyp string, p event.Parser) {
|
|||
|
||||
func initState(c *cfg) {
|
||||
epoch, err := c.cfgNetmap.wrapper.Epoch()
|
||||
if err != nil {
|
||||
fatalOnErr(fmt.Errorf("could not initialize current epoch number: %w", err))
|
||||
}
|
||||
|
||||
ni, err := c.netmapLocalNodeState(epoch)
|
||||
if err != nil {
|
||||
fatalOnErr(fmt.Errorf("could not init network state: %w", err))
|
||||
}
|
||||
|
||||
c.handleNodeInfoStatus(ni)
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ func (v *FormatValidator) Validate(obj *Object) error {
|
|||
|
||||
// TODO: combine small checks
|
||||
if err := v.checkExpiration(obj); err != nil {
|
||||
return fmt.Errorf("object did not pass expiration ch: %weck", err)
|
||||
return fmt.Errorf("object did not pass expiration check: %w", err)
|
||||
}
|
||||
|
||||
if err := object.CheckHeaderVerificationFields(obj.SDK()); err != nil {
|
||||
|
|
|
@ -157,11 +157,13 @@ func (p *Streamer) SendChunk(prm *PutChunkPrm) error {
|
|||
return errNotInit
|
||||
}
|
||||
|
||||
_, err := p.target.Write(prm.chunk)
|
||||
|
||||
if _, err := p.target.Write(prm.chunk); err != nil {
|
||||
return fmt.Errorf("(%T) could not write payload chunk to target: %w", p, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Streamer) Close() (*PutResponse, error) {
|
||||
if p.target == nil {
|
||||
return nil, errNotInit
|
||||
|
|
Loading…
Reference in a new issue