From a36fe24b8383f6cd9b3519cd3eabdb9675d8992d Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Fri, 21 Jul 2023 11:51:35 +0200 Subject: all: use errors.As instead of .(type) --- pkg/instance/instance.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg/instance/instance.go') diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index ea4084def..7696a945d 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -7,6 +7,7 @@ package instance import ( "encoding/json" + "errors" "fmt" "net" "os" @@ -305,7 +306,8 @@ func (inst *inst) test() EnvTestResult { ret := EnvTestResult{ Error: testErr, } - if bootErr, ok := err.(vm.BootErrorer); ok { + var bootErr vm.BootErrorer + if errors.As(err, &bootErr) { testErr.Title, testErr.Output = bootErr.BootError() ret.RawOutput = testErr.Output rep := inst.reporter.Parse(testErr.Output) @@ -327,7 +329,8 @@ func (inst *inst) test() EnvTestResult { testErr.Title = rep.Title } else { testErr.Infra = true - if infraErr, ok := err.(vm.InfraErrorer); ok { + var infraErr vm.InfraErrorer + if errors.As(err, &infraErr) { // In case there's more info available. testErr.Title, testErr.Output = infraErr.InfraError() } -- cgit mrf-deployment