summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd_command.go10
-rw-r--r--ez.go7
2 files changed, 8 insertions, 9 deletions
diff --git a/cmd_command.go b/cmd_command.go
index 700e47d..32292d3 100644
--- a/cmd_command.go
+++ b/cmd_command.go
@@ -75,7 +75,7 @@ func (c CmdCommit) fiCmdWrite(fiw fiWriter) error {
func init() { parser_registerCmd("commit ", CmdCommit{}) }
func (CmdCommit) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez := &ezfir{fir: fir}
- defer func() { err = ez.Defer() }()
+ defer ez.Defer(&err)
// 'commit' SP <ref> LF
c := CmdCommit{Ref: trimLinePrefix(ez.ReadLine(), "commit ")}
@@ -176,7 +176,7 @@ func (c CmdTag) fiCmdWrite(fiw fiWriter) error {
func init() { parser_registerCmd("tag ", CmdTag{}) }
func (CmdTag) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez := &ezfir{fir: fir}
- defer func() { err = ez.Defer() }()
+ defer ez.Defer(&err)
// 'tag' SP <name> LF
c := CmdTag{RefName: trimLinePrefix(ez.ReadLine(), "tag ")}
@@ -237,7 +237,7 @@ func (c CmdReset) fiCmdWrite(fiw fiWriter) error {
func init() { parser_registerCmd("reset ", CmdReset{}) }
func (CmdReset) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez := &ezfir{fir: fir}
- defer func() { err = ez.Defer() }()
+ defer ez.Defer(&err)
// 'reset' SP <ref> LF
c := CmdReset{RefName: trimLinePrefix(ez.ReadLine(), "reset ")}
@@ -281,7 +281,7 @@ func (c CmdBlob) fiCmdWrite(fiw fiWriter) error {
func init() { parser_registerCmd("blob\n", CmdBlob{}) }
func (CmdBlob) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez := &ezfir{fir: fir}
- defer func() { err = ez.Defer() }()
+ defer ez.Defer(&err)
// 'blob' LF
_ = ez.ReadLine()
@@ -325,7 +325,7 @@ func (c CmdAlias) fiCmdWrite(fiw fiWriter) error {
func init() { parser_registerCmd("alias\n", CmdCheckpoint{}) }
func (CmdAlias) fiCmdRead(fir fiReader) (cmd Cmd, err error) {
ez := &ezfir{fir: fir}
- defer func() { err = ez.Defer() }()
+ defer ez.Defer(&err)
// 'alias' LF
_ = ez.ReadLine()
diff --git a/ez.go b/ez.go
index be57d58..a1dbfca 100644
--- a/ez.go
+++ b/ez.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2017 Luke Shumaker <lukeshu@lukeshu.com>
+// Copyright (C) 2017, 2021 Luke Shumaker <lukeshu@lukeshu.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -51,7 +51,7 @@ type ezfir struct {
var ezPanic = errors.New("everything is fine")
-func (e *ezfir) Defer() error {
+func (e *ezfir) Defer(err *error) {
if e.err != nil {
r := recover()
if r == nil {
@@ -60,9 +60,8 @@ func (e *ezfir) Defer() error {
if r != ezPanic {
panic(r)
}
- return e.err
+ *err = e.err
}
- return nil
}
func (e *ezfir) Errcheck(err error) {