]> Cypherpunks repositories - gostls13.git/commitdiff
exp/template: include function name in error returned by function or method call.
authorRob Pike <r@golang.org>
Thu, 14 Jul 2011 01:32:06 +0000 (11:32 +1000)
committerRob Pike <r@golang.org>
Thu, 14 Jul 2011 01:32:06 +0000 (11:32 +1000)
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/4711049

src/pkg/exp/template/exec.go
src/pkg/exp/template/exec_test.go

index a7af9b496b0704eadeeda6f68746d960da29693b..6b0758045debb13a8520f4a121aa27153636049a 100644 (file)
@@ -455,7 +455,7 @@ func (s *state) evalCall(dot, fun reflect.Value, name string, args []node, final
        result := fun.Call(argv)
        // If we have an os.Error that is not nil, stop execution and return that error to the caller.
        if len(result) == 2 && !result[1].IsNil() {
-               s.error(result[1].Interface().(os.Error))
+               s.errorf("error calling %s: %s", name, result[1].Interface().(os.Error))
        }
        return result[0]
 }
index 7e0301c8d8459c09af4b7c3eb4998894972a0d8f..112adbf246180a9b6c90a02dab614fbfc2fa3138 100644 (file)
@@ -395,6 +395,9 @@ func TestExecuteError(t *testing.T) {
        if err == nil {
                t.Errorf("expected error; got none")
        } else if !strings.Contains(err.String(), os.EPERM.String()) {
+               if *debug {
+                       fmt.Printf("test execute error: %s\n", err)
+               }
                t.Errorf("expected os.EPERM; got %s", err)
        }
 }