Win32::OLE and exceptions handling

R

RedAktor

Hi,

I've got one problem with it. I've try to use Error.pm and also set
OLE->Warn param to sub i.e &HandleError. And it catches errors in both ways,
but it doesn't pass OLE error number. In both ways Win32::OLE->LastError()
returns 0. Is there another way to catch the error, get its number and
gently handle it? I'm including ways I've tried to do this:

1st
--------------
Win32::OLE->Option(Warn => &HandleError(Win32::OLE->LastError()));

sub HandleError {
$err = shift;
if ($err == HRESULT(0x80020009)) {
print "Error \n";
exit;
}
}

2nd
-----------------------------
try {
$doc = $docs->Item($di);
$err=Win32::OLE->LastError();
throw Error::Simple $err;
}
catch Error with {
my $E = shift;
print $E;
die;
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top