Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Detecting read errors whilst reading from a network drive

by crabbdean (Pilgrim)
on Apr 14, 2004 at 12:07 UTC ( #345008=note: print w/ replies, xml ) Need Help??


in reply to Detecting read errors whilst reading from a network drive

In general yes you'll get an error. The error will be pretty much similar to the one if you had a read error on a local drive. You should try using  or die $!; if you want the reasons for the error to be output. At least then your 'die' is a little informative.

If you want the bells and whistles version you could drop the below into your code and call it with dying($!) instead. If you don't want the bells remove the 'sound' related lines I appended with ##>> and if you don't want the error message brutally forced to the front of all your other applications remove the 'win32Util' lines that I appended with ##%%

Happy travels! :-)

## put into the top of your main code ## Show fatal error dialog sub dying { my ($error) = @_; use Tk; use Win32::Sound; ##>> use Win32Util; ##%% if (!$error) { $error = "(none given)"; } my $text; $text .= "\n\nError:\n\n$error"; my $box = new MainWindow(-title => "Error", -bg => 'yellow', -bd => 4, -relief => 'ridge'); $box->overrideredirect(1); my $label = $box->Label( -textvariable=> \$text, -bg=> 'yellow', )->pack(-fill=>'both', -padx => 40, ); Win32::Sound::Play('SystemExclamation'); ##>> my $ok = $box->Button(-text => "OK", -command => [ sub{print STDOUT "User selected 'OK' + on error message\n"; $box->destroy; exit; } ] )->pack(-padx => 20, -pady => 20 ); $box->withdraw; $box->Popup; Win32Util::keep_on_top($box, 1); ##%% MainLoop; }

Dean
The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers


Comment on Re: Detecting read errors whilst reading from a network drive
Select or Download Code
Re: Re: Detecting read errors whilst reading from a network drive
by Anonymous Monk on Apr 14, 2004 at 12:24 UTC
    The file is already open. He's reading the file. There is a network failure and he can't read the file anymore. There should be an error in $! and $^E.
      Well yes. But if the only indicator that your network just failed is the $! and $^E then I'd suggest hiring better network administrator and getting better network monitors haha! Sorry couldn't resist. :-) I just get see the chaos that goes on around my work when the network dies. haha. I was running a script once when my network went down. Besides the thought of "Oh hell, did I just do that?" it was pretty obvious why my script failed.

      Dean
      The Funkster of Mirth
      Programming these days takes more than a lone avenger with a compiler. - sam
      RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://345008]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2014-12-28 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls