File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ func doExpandMacro(expr types.Expr) (types.Value, error) {
87
87
return val , err
88
88
}
89
89
90
- func writeTrxLog (ctx context.Context , expr types.Expr ) error {
90
+ func writeTrxLog (ctx context.Context , expr types.Expr ) ( result error ) {
91
91
deparsed , err := Deparse (expr )
92
92
if err != nil {
93
93
return errors .Wrap (err , "failed to deparse expression" )
@@ -112,13 +112,14 @@ func writeTrxLog(ctx context.Context, expr types.Expr) error {
112
112
if err != nil {
113
113
return errors .Wrapf (err , "could not create %s" , filename )
114
114
}
115
+ defer func () {
116
+ if err := logFile .Close (); err != nil {
117
+ result = errors .Wrapf (err , "failed to close transaction log %s" , filename )
118
+ }
119
+ }()
115
120
_ , err = io .Copy (logFile , bytes .NewReader (content ))
116
121
if err != nil {
117
122
return errors .Wrapf (err , "failed to write transaction log %s" , filename )
118
123
}
119
- err = logFile .Close ()
120
- if err != nil {
121
- return errors .Wrapf (err , "failed to close transaction log %s" , filename )
122
- }
123
124
return nil
124
125
}
You can’t perform that action at this time.
0 commit comments