gopherdata/gophernotes

internal error: proxy not found for interface type <error>

xdays opened this issue · 2 comments

xdays commented

Here's my code:

import (
    "fmt"
    "log"
    "errors"
)

type sqrError struct{
    lat string
    long string
    err error
}

func (se sqrError) Error() string {
    return fmt.Sprintf("math error: %v %v %v", se.lat, se.long, se.err)
}

func test4() {
    _, err := sqrt(-10)
    if err != nil {
        log.Println(err)
    }
}

func sqrt(f float64) (float64, error) {
    if f<0 {
        e := errors.New("more cola needed")
        return 0, sqrError{"50 N", "99 W", e}
    }
    return 42, nil
}
test4()

result is:

repl.go:122:19: internal error: proxy not found for interface type <error>

Here's code from play.golang.org https://play.golang.org/p/gXuiTQmUroW

and result is:

2009/11/10 23:00:00 math error: 50 N 99 W more cola needed

Thanks!

ops, my fault!
There's a lot of code to allow interpreted types to implement interfaces, yet somehow I forgot about the humble error.
Fixing it.

Fixed in 3f7b312

Please note that log.Println(err) will write to jupyter console, which may not be visible.
In order to print to the currently open notebook, use fmt.Println(err)