always wrap errors when creating new ones with fmt.Errorf()

It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
This commit is contained in:
Roman Khimov 2020-08-06 19:09:57 +03:00
parent 205f52c563
commit 0e2784cd2c
24 changed files with 105 additions and 84 deletions

View file

@ -140,15 +140,15 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
}
b, di, err := CompileWithDebugInfo(bytes.NewReader(b))
if err != nil {
return nil, fmt.Errorf("error while trying to compile smart contract file: %v", err)
return nil, fmt.Errorf("error while trying to compile smart contract file: %w", err)
}
f, err := nef.NewFile(b)
if err != nil {
return nil, fmt.Errorf("error while trying to create .nef file: %v", err)
return nil, fmt.Errorf("error while trying to create .nef file: %w", err)
}
bytes, err := f.Bytes()
if err != nil {
return nil, fmt.Errorf("error while serializing .nef file: %v", err)
return nil, fmt.Errorf("error while serializing .nef file: %w", err)
}
out := fmt.Sprintf("%s.%s", o.Outfile, o.Ext)
err = ioutil.WriteFile(out, bytes, os.ModePerm)