cue
cue copied to clipboard
cue: provide a way of creating an error Value
The cue API extensively uses the capability to return Values holding an error rather than
return (Value, error) pairs. However, there is no way to use the API to create a Value holding
an arbitrary error. This means that it's not easily possible for non-core packages to provide
a similar API or to wrap the cue API while preserving the same style of interface.
We should provide this capability, for example by adding a method like this:
package cue
// Error returns a new Value holding the given error.
func (ctx *Context) Error(err error) Value
Another possibility might be to overload Context.Encode: if its argument implements error, it could
return an error value.