Skip to content

refactor: replace type assertion on errors#530

Merged
tenthirtyam merged 1 commit intomainfrom
refactor/replaces-type-assertion
May 21, 2025
Merged

refactor: replace type assertion on errors#530
tenthirtyam merged 1 commit intomainfrom
refactor/replaces-type-assertion

Conversation

@tenthirtyam
Copy link
Copy Markdown
Collaborator

Replaces type assertion on errors with a call to errors.As.

The preferred way for checking for a specific error type is to use the errors.As function from the standard library as this function traverses the chain of the wrapped errors while checking for a specific error type.

~/Downloads/packer-plugin-vsphere git:[refactor/replaces-type-assertion]
go fmt ./...

~/Downloads/packer-plugin-vsphere git:[refactor/replaces-type-assertion]
make build

~/Downloads/packer-plugin-vsphere git:[refactor/replaces-type-assertion]
make test
?       github.com/hashicorp/packer-plugin-vsphere      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone        1.702s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common       3.275s
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/testing       [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/utils [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver       7.996s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso  3.439s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/supervisor   6.217s
?       github.com/hashicorp/packer-plugin-vsphere/examples/driver      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere       2.157s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere-template      1.675s
?       github.com/hashicorp/packer-plugin-vsphere/version      [no test files]

Replaces type assertion on errors with a call to `errors.As`.

The preferred way for checking for a specific error type is to use the `errors.As` function from the standard library as this function traverses the chain of the wrapped errors while checking for a specific error type.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
@tenthirtyam tenthirtyam added this to the v2.0.0 milestone May 20, 2025
@tenthirtyam tenthirtyam requested a review from JenGoldstrich May 20, 2025 23:31
@tenthirtyam tenthirtyam self-assigned this May 20, 2025
@tenthirtyam tenthirtyam requested a review from a team as a code owner May 20, 2025 23:31
@tenthirtyam tenthirtyam added technical-debt Technical Debt refactor Refactor labels May 20, 2025
@tenthirtyam tenthirtyam merged commit 650c9da into main May 21, 2025
14 checks passed
@tenthirtyam tenthirtyam deleted the refactor/replaces-type-assertion branch May 21, 2025 15:29
tenthirtyam added a commit that referenced this pull request May 21, 2025
Fix the type assertion on errors to use the `*object.DatastoreNoSuchDirectoryError` pointer.

Follow-up to #530.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
tenthirtyam added a commit that referenced this pull request May 22, 2025
Replaces type assertion on errors with a call to `errors.As`.

The preferred way for checking for a specific error type is to use the `errors.As` function from the standard library as this function traverses the chain of the wrapped errors while checking for a specific error type.

Signed-off-by: Ryan Johnson <ryan.johnson@broadcom.com>
@github-actions
Copy link
Copy Markdown

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

refactor Refactor technical-debt Technical Debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants