package fixture import "fmt" // Not compiled. MV-N2's format, with its list made by a package helper or // read from a string field. Each carries an error's text, or text the gate // cannot derive, and no row vouches for that. func detail(err error) string { return err.Error() } func viaHelper(w int, to string, err error) { jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, detail(err))) } func viaHelperConcat(w int, to string, err error) { jsonError(w, 400, "region "+to+" is not one of this app's regions: "+detail(err)) } // A helper whose return the gate cannot derive: the receiver is shadowed, so // the gate cannot tell which describe runs. type local struct{} func (local) describe() string { return "a recorded sentence" } func opaque(x local, y thing) string { if x := y; x != nil { return x.describe() } return "a recorded sentence" } func viaOpaque(w int, to string, x local, y thing) { jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, opaque(x, y))) } // A helper that returns its parameter, bound to an error's text. func echo(m string) string { return m } func viaEcho(w int, to string, err error) { jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, echo(fmt.Sprint(err)))) } // A string field written from an error's text. type failure struct{ Detail string } func record(err error) failure { return failure{Detail: err.Error()} } func viaField(w int, to string, f failure) { jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, f.Detail)) } func viaFieldConcat(w int, to string, f failure) { jsonError(w, 400, "region "+to+" is not one of this app's regions: "+f.Detail) }