Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors not throwing actual error. #8

Closed
nwsparks opened this issue Mar 31, 2017 · 1 comment
Closed

Errors not throwing actual error. #8

nwsparks opened this issue Mar 31, 2017 · 1 comment
Assignees

Comments

@nwsparks
Copy link

The functions are throwing custom errors rather than passing the original error back out which is problematic. I ran into an issue when trying to wrap your module into another function where the drsrule functions were failing because I wasn't importing the vmware module into the global scope. So rather than the error displaying what was really happening (get-vm command not found) it was saying the vm itself wasn't found which was not the issue at all.

I changed the below with a possible alternative

          try {
            ## limit scope to this cluster
            $oThisCluster | Get-VM -Name $oThisVmItem -ErrorAction:Stop
          }
          catch {
          #this commented out is the original message
          #Throw "No VM of name '$oThisVmItem' found in cluster '$($oThisCluster.Name)'. Valid VM name?"
          Throw "$($oThisCluster.Name) - Error looking up $oThisVmItem - $($_.Exception.Message)"
          }
@mtboren mtboren self-assigned this Apr 2, 2017
@mtboren
Copy link
Member

mtboren commented Apr 2, 2017

Greets, @nwsparks --

Ah, yes, I can see how that is problematic. I will look into enhancing the module such it returns info about the "real" error that happens, not some assumption about what happened. Thanks for the sample snippet, too.

@mtboren mtboren closed this as completed in 0afc2fc Jul 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants