Win32::OLE and exceptions handling

Discussion in 'Perl Misc' started by RedAktor, Jul 30, 2003.

  1. RedAktor

    RedAktor Guest

    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;
    };

    --------------------------

    TIA
    Andrew
    Ps. Sorry for my English ;)
     
    RedAktor, Jul 30, 2003
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl
    Replies:
    1
    Views:
    5,640
    Jay Tilton
    Jun 25, 2003
  2. Patrick.O.Ige

    Ole ole

    Patrick.O.Ige, Jul 16, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    697
    Patrick.O.Ige
    Jul 16, 2006
  3. Drew Pihera
    Replies:
    0
    Views:
    897
    Drew Pihera
    Feb 4, 2004
  4. M. David Allen

    Win32::OLE, Excel, and coloring

    M. David Allen, Jun 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    277
    Jay Tilton
    Jun 25, 2003
  5. Richard S Beckett

    Win32-OLE, excel, and empties.

    Richard S Beckett, Jul 11, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    366
    Jay Tilton
    Jul 11, 2003
  6. Shaun Clowes

    Win32::OLE and CDO Message Filters

    Shaun Clowes, Nov 11, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    395
    Shaun Clowes
    Nov 12, 2003
  7. Lance Hoffmeyer
    Replies:
    0
    Views:
    524
    Lance Hoffmeyer
    Nov 17, 2003
  8. Domenico Discepola

    Win32::OLE and creation of pivot table in Excel

    Domenico Discepola, Dec 3, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    1,112
    Domenico Discepola
    Dec 4, 2003
Loading...