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) --- vm/vmimpl/vmimpl.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'vm/vmimpl/vmimpl.go') diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index 9dbd61a92..0a4ada028 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -93,12 +93,11 @@ type BootError struct { } func MakeBootError(err error, output []byte) error { - switch err1 := err.(type) { - case *osutil.VerboseError: - return BootError{err1.Title, append(err1.Output, output...)} - default: - return BootError{err.Error(), output} + var verboseError *osutil.VerboseError + if errors.As(err, &verboseError) { + return BootError{verboseError.Title, append(verboseError.Output, output...)} } + return BootError{err.Error(), output} } func (err BootError) Error() string { -- cgit mrf-deployment