fix: return on vm error

This commit is contained in:
Anthony Laibe 2023-03-29 09:03:43 +02:00 committed by Anthony Laibe
parent 1189fb882e
commit eb4257a904
1 changed files with 16 additions and 0 deletions

View File

@ -126,6 +126,7 @@ func (c *ClientWithFallback) makeCallNoReturn(main func() error, fallback func()
if err != nil { if err != nil {
if isVMError(err) { if isVMError(err) {
resultChan <- CommandResult{vmError: err} resultChan <- CommandResult{vmError: err}
return nil
} }
return err return err
} }
@ -139,6 +140,10 @@ func (c *ClientWithFallback) makeCallNoReturn(main func() error, fallback func()
err = fallback() err = fallback()
if err != nil { if err != nil {
if isVMError(err) {
resultChan <- CommandResult{vmError: err}
return nil
}
c.IsConnected = false c.IsConnected = false
return err return err
} }
@ -166,6 +171,7 @@ func (c *ClientWithFallback) makeCallSingleReturn(main func() (any, error), fall
if err != nil { if err != nil {
if isVMError(err) { if isVMError(err) {
resultChan <- CommandResult{vmError: err} resultChan <- CommandResult{vmError: err}
return nil
} }
return err return err
} }
@ -179,6 +185,10 @@ func (c *ClientWithFallback) makeCallSingleReturn(main func() (any, error), fall
res, err := fallback() res, err := fallback()
if err != nil { if err != nil {
if isVMError(err) {
resultChan <- CommandResult{vmError: err}
return nil
}
c.IsConnected = false c.IsConnected = false
return err return err
} }
@ -186,6 +196,7 @@ func (c *ClientWithFallback) makeCallSingleReturn(main func() (any, error), fall
resultChan <- CommandResult{res1: res} resultChan <- CommandResult{res1: res}
return nil return nil
}) })
select { select {
case result := <-resultChan: case result := <-resultChan:
if result.vmError != nil { if result.vmError != nil {
@ -205,6 +216,7 @@ func (c *ClientWithFallback) makeCallDoubleReturn(main func() (any, any, error),
if err != nil { if err != nil {
if isVMError(err) { if isVMError(err) {
resultChan <- CommandResult{vmError: err} resultChan <- CommandResult{vmError: err}
return nil
} }
return err return err
} }
@ -218,6 +230,10 @@ func (c *ClientWithFallback) makeCallDoubleReturn(main func() (any, any, error),
a, b, err := fallback() a, b, err := fallback()
if err != nil { if err != nil {
if isVMError(err) {
resultChan <- CommandResult{vmError: err}
return nil
}
c.IsConnected = false c.IsConnected = false
return err return err
} }