Go: more verbose error reporting on set_option

This commit is contained in:
Alex Beregszaszi 2018-09-05 18:25:22 +01:00
parent 50c254fb98
commit 97a559c712
1 changed files with 5 additions and 1 deletions

View File

@ -188,8 +188,12 @@ func (instance *Instance) Version() string {
func (instance *Instance) SetOption(name string, value string) (err error) {
r := C.set_option(instance.handle, C.CString(name), C.CString(value))
if r != C.EVMC_SET_OPTION_SUCCESS {
switch r {
case C.EVMC_SET_OPTION_INVALID_NAME:
err = fmt.Errorf("evmc: option '%s' not accepted", name)
case C.EVMC_SET_OPTION_INVALID_VALUE:
err = fmt.Errorf("evmc: option '%s' has invalid value", name)
case C.EVMC_SET_OPTION_SUCCESS:
}
return err
}