Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Handling Errors from COM components

Closed Thread
 
Thread Tools Display Modes
Old 10-17-2006   #1 (permalink)
peterchen
Guest


 

Handling Errors from COM components

I have some problems handling Errors returned after invoking a
COM/Automation object.

I read the "Sapiens TFM" sample chapter (which explains things quite
clearly I thought) but I am missing something

I would be happy with the original error text, plus the script
terminating. However, here's what I see:

I have a dev.ps1 script that defines a global function, which creates
an Automation object, passes this to a local function, which uses it.
The following happens if the call on the Automation Object returns an
error:

(1) Without "trap", poweshell displays an error (location of call, and
error message from Automation object). Very useful! Unfortunately, the
script continues with the next command

(2) A "trap" added to the top of the script file gets never called.
Same Behavior as under (1)

(3) A "trap" added to the actual function calling the COM object gets
called, but the $_ object seems empty. neither Write-Host $_ nor
Write-Host $_.Exception.Message display anything. However, I could
"Throw" here to terminate the script, but this displays no helpful
message.

Any ideas?

Trap {
Write-Host "ERRORINNER"
Write-Host $_.Exception.Message
Throw
}

thanks!

Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Uh-Oh are my main components too hot!?! isikh Overclocking & Cooling 11 2 Weeks Ago 01:53 AM
handling errors in a script Darren Mar-Elia PowerShell 4 11-29-2007 07:56 PM
Do I need these Windows components? Larry E Vista General 4 11-18-2007 07:21 AM
explorer errors, program errors, no task manager EmilyD Vista performance & maintenance 3 11-13-2007 09:14 PM
What are Serviceable Components? Shayne H Vista installation & setup 3 11-11-2007 08:15 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50