Search Results

Search found 38423 results on 1537 pages for 'try finally'.

Page 7/1537 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Why use tryfinally without a catch clause?

    - by Nick Rosencrantz
    The classical way to program is with try / catch but when is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do something unconditional But we didn't catch anything. Similarly one could think in Java it would be try { //for example try to get a database connection } finally { //closeConnection(connection) } It looks good and suddenly I don't have to worry about exception types etc. But if this is good practice, when is it good practice? Or reasons why this is not good practice or not legal (I didn't compile the source I'm asking about and it could be a syntax error for Java but I checked that the Python surely compiles.) A related problem I've run into is that I continue writing the function / method and at the end I must return something and I'm in a place which should not be reached and it must be a return point so even if I handle the exceptions above I'm still returning null or an empty string at some point in the code which should not be reached, often the end of the method / function. I've always managed to restructure to code so that I don't have to return null since that absolutely appears to look like less than good practice.

    Read the article

  • Subterranean IL: Compiling C# exception handlers

    - by Simon Cooper
    An exception handler in C# combines the IL catch and finally exception handling clauses into a single try statement: try { Console.WriteLine("Try block") // ... } catch (IOException) { Console.WriteLine("IOException catch") // ... } catch (Exception e) { Console.WriteLine("Exception catch") // ... } finally { Console.WriteLine("Finally block") // ... } How does this get compiled into IL? Initial implementation If you remember from my earlier post, finally clauses must be specified with their own .try clause. So, for the initial implementation, we take the try/catch/finally, and simply split it up into two .try clauses (I have to use label syntax for this): StartTry: ldstr "Try block" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End EndTry: StartIOECatch: ldstr "IOException catch" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End EndIOECatch: StartECatch: ldstr "Exception catch" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End EndECatch: StartFinally: ldstr "Finally block" call void [mscorlib]System.Console::WriteLine(string) // ... endfinally EndFinally: End: // ... .try StartTry to EndTry catch [mscorlib]System.IO.IOException handler StartIOECatch to EndIOECatch catch [mscorlib]System.Exception handler StartECatch to EndECatch .try StartTry to EndTry finally handler StartFinally to EndFinally However, the resulting program isn't verifiable, and doesn't run: [IL]: Error: Shared try has finally or fault handler. Nested try blocks What's with the verification error? Well, it's a condition of IL verification that all exception handling regions (try, catch, filter, finally, fault) of a single .try clause have to be completely contained within any outer exception region, and they can't overlap with any other exception handling clause. In other words, IL exception handling clauses must to be representable in the scoped syntax, and in this example, we're overlapping catch and finally clauses. Not only is this example not verifiable, it isn't semantically correct. The finally handler is specified round the .try. What happens if you were able to run this code, and an exception was thrown? Program execution enters top of try block, and exception is thrown within it CLR searches for an exception handler, finds catch Because control flow is leaving .try, finally block is run The catch block is run leave.s End inside the catch handler branches to End label. We're actually running the finally before the catch! What we do about it What we actually need to do is put the catch clauses inside the finally clause, as this will ensure the finally gets executed at the correct time (this time using scoped syntax): .try { .try { ldstr "Try block" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End } catch [mscorlib]System.IO.IOException { ldstr "IOException catch" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End } catch [mscorlib]System.Exception { ldstr "Exception catch" call void [mscorlib]System.Console::WriteLine(string) // ... leave.s End } } finally { ldstr "Finally block" call void [mscorlib]System.Console::WriteLine(string) // ... endfinally } End: ret Returning from methods There is a further semantic mismatch that the C# compiler has to deal with; in C#, you are allowed to return from within an exception handling block: public int HandleMethod() { try { // ... return 0; } catch (Exception) { // ... return -1; } } However, you can't ret inside an exception handling block in IL. So the C# compiler does a leave.s to a ret outside the exception handling area, loading/storing any return value to a local variable along the way (as leave.s clears the stack): .method public instance int32 HandleMethod() { .locals init ( int32 retVal ) .try { // ... ldc.i4.0 stloc.0 leave.s End } catch [mscorlib]System.Exception { // ... ldc.i4.m1 stloc.0 leave.s End } End: ldloc.0 ret } Conclusion As you can see, the C# compiler has quite a few hoops to jump through to translate C# code into semantically-correct IL, and hides the numerous conditions on IL exception handling blocks from the C# programmer. Next up: catch-all blocks, and how the runtime deals with non-Exception exceptions.

    Read the article

  • Windows Media Center says "Searching for tuners" when I try to play live TV

    - by Louis
    After upgrading from Windows 8 Pro with Media Center to the 8.1 preview, I need some help in being able to watch live TV again. When I try to now, it says Please Wait. Searching for tuners. I tried reinstalling the software for the Hauppauge WinTV DCR-2650 TV tuner, and upgrading the firmware for both the tuner and the Cisco STA-1520 tuning adapter. I also tried swapping around the USB ports, cold-booting the devices, and running the Set Up TV Signal setting in WMC, but that says The TV signal cannot be configured because a TV tuner was not detected. Both devices look fine in Device Manager, reporting the "This device is working properly" status. I'm not sure if this is related, but I did have some network connectivity issues immediately after upgrading to Windows 8.1 where my either my subnet mask or default gateway was missing, and since the TV tuner shows up as a network device, I wonder if that might be related. However, I really don't know how those settings should look and Hyper-V sort of further complicates things with the virtual Ethernet adapters:

    Read the article

  • Lemonldap::ng + OpenID error in try generate

    - by spy86
    I am trying to configure authentication by OpenID in lemonldap::ng with this When I try http://auth.example.com/openidserver/username, I see following error: Unable to load Net::OpenID::Server Base class package "Net::OpenID::Server" is empty. (Perhaps you need to 'use' the module which defines that package first, or make that module available in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /etc/httpd). at /usr/share/perl5/vendor_perl/Lemonldap/NG/Portal/OpenID/Server.pm line 9 BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/Lemonldap/NG/Portal/OpenID/Server.pm line 9, line 522. Compilation failed in require at /usr/share/perl5/vendor_perl/Lemonldap/NG/Portal/IssuerDBOpenID.pm line 40, line 522. LemonLDAP::NG Lemonldap::ng works in CentOS 6.4 and server have all update's

    Read the article

  • Ubuntu Deluge shows errors when downloading large bit torrent files and keeps erroring out after try

    - by MikeN
    Ubuntu Deluge shows errors when downloading large bit torrent files and keeps erroring out after trying to resume. The error on details shows: "Invalid argument". This happens for many large torrents that are running for several days (trying to download.) I try to "resume" and "force rechceck" but it never works. Smaller torrents seem to work ok. What is causing these torrents to never complete? Is there a way to force Deluge to keep auto-resuming every few minutes after a failure instead of just giving up?

    Read the article

  • webmin bind issue- error when i try to start bind

    - by Arvind
    I am setting up a domain = mydomain.com with 2 nameservers ns1.mydomain.com and ns2.mydomain.com in Webmin - BIND. For this, I have registered 2 child nameservers at my domain registrar, and in Webmin-Bind I have set up a new zone for this domain. In this zone, i have specified 2 nameserver records- one each for ns1 and ns2. Also, I have defined 2 address records- one each for ns1.mydomain.com -> IP Address #1 and for ns2.mydomain.com -> IP Address #2 However when I try to start BIND in Webmin, I get the following error-- Failed to start BIND : Starting named: Error in named configuration: zone mydomain.com/IN: has no NS records zone mydomain.com/IN: not loaded due to errors. _default/mydomain.com/IN: bad zone [FAILED]

    Read the article

  • Graphics card failure, anything I could try...

    - by ILMV
    My gaming PC has decided to die, it's not the first time but usually a quick ATX reset brings it back to life. Today it didn't. I disconnect all unessasary devices so I've only got the case button / LED cables, GPU, CPU, RAM and power connected, the computer still didn't turn on. I've not got a speaker on my motherboard so found a spare one I have for testing and when the machine starts up I get one long beep and two short beeps from my Award BIOS, which apparently means a video card error. I change it with the GPU from another machine and all works well. Q: So I have a faulty graphics card (an nVidia 8800GT OC), is there anything I can try to resurect it?

    Read the article

  • XenServer 6.2 crashes everytime I try to install a new Windows 7 x64 vm

    - by Erik
    I'm running XenServer 6.2 with all patches and updates on two boxes. One box is an intel core i7 2600K.. works great. My latest box is an AMD A10 APU.. and everytime I try to install Windows 7 OS as a guest.. I get to the screen where Windows files start to expand, and suddenly the entire box freezes up. Is there a log I can check, and or a way to migrate a working Windows 7 image I created on Box 1 over to Box 2?

    Read the article

  • Try exchange in real domain

    - by AndreaCi
    We (as a company) 'd like to try exchange server to replace our mail server. I downloaded the demo version from Microsoft website, but during the installation it wants administrator access to domain to edit the Active Directory database structure. The test will last for (at least) a month to see if it will bring real advantages to our management systems. Here is my question: Is it "dangerous"? If I uninstall the exchange server everything will be reverted to previous state? I'm kind of "scared" about the changes he may apply to our domain controllers.

    Read the article

  • Visual Studio 2008 crashes whenever I try to add a file to TFS

    - by Herms
    Wondering if anyone else has seen this or knows of a way to fix it. I have Visual Studio 2008 Pro with Team Explorer 2008 installed. Starting a couple of weeks ago any time I try to add a file to TFS (using the "Add Items to Folder" button in the Source Control Explorer window) VS crashes. I briefly see an "unhandled exception" dialog appear, but VS quits right after the dialog opens. I was able to see the exception at one point, and it looked like an index out of bounds exception trying to access some UI component list at -1 (can't remember the specifics, and it closes before I can bring it up now). I've tried uninstalling and reinstalling VS a couple of times already, along with resetting all of my settings. Neither helped.

    Read the article

  • How to show why "try" failed in python

    - by calccrypto
    is there anyway to show why a "try" failed, and skipped to "except", without writing out all the possible errors by hand, and without ending the program? example: try: 1/0 except: someway to show "Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> 1/0 ZeroDivisionError: integer division or modulo by zero" i dont want to doif:print error 1, elif: print error 2, elif: etc.... i want to see the error that would be shown had try not been there

    Read the article

  • php crashes when I try to add extensions

    - by Christy
    Hi all, I am trying to install phpmyadmin on my web server with Windows 2008 and iis 7. PHP is running fine and I have several sites that rely on it. When installing phpmyadmin - it has errors at the bottom that crypt and mbstring are not properly installed. When I try to add the php_mcrypt.dll and/or the php_mbstring.dll to the php.ini file (I verified the location and the right file through phpinfo) it crashes. I get a 500 error on all the websites, and I get an error on the server saying FastCGI has failed. Does anyone know how to fix this or why it is happening? Shouldn't I be able to add extenstions? I have the dll files in the extension folder, which is referenced in the php.ini and other extensions (installed previously) are working as expected. Other info: php version 5.2.8, pdo driver for mysql version 5.0.51a Thanks in advance!

    Read the article

  • "input cannot be resolved" when added a try..catch

    - by Mark
    I originally tried to get my throw statement to work without a try catch and the userInput = input.nextInt(); line worked fine. But when I tried adding the try..catch it didn't like my input saying it cannot be resolved. I don't think my try..catch is correct yet but I am planning on tackling that after I can get this input to be recognized but I would appreciate any feedback on things you see with that as well. Thanks import java.util.Scanner; public class Program6 { public static void main(String[] args) { final int NUMBER_HIGH_LIMIT = 100; final int NUMBER_LOW_LIMIT = 10; int userInput; try { System.out.print("Enter a number between 10 and 100: "); userInput = input.nextInt();//Says input cannot be resolved Verify v = new Verify(NUMBER_HIGH_LIMIT, NUMBER_LOW_LIMIT); } catch(NumberHighException exception) { userInput = 0; } catch(NumberLowException exception) { userInput = 0; } } }

    Read the article

  • All program links (icons, menu items) try to use Adobe Reader to run them

    - by Rob
    My mother was opening Internet Mail to check her mail on her new Windows 7 PC and a pop-up window asked her if she wanted to use Adobe Reader as the default program instead. She must have clicked yes. Now all of the Start Menu and Desktop icons have the adobe logo and appear to try and use adobe to execute the programs. Has anyone encountered this and were they able to fix it? She tried to associate another program and ended up having the Internet Explorer icon and program replacing the Adobe icons. This woman can tear up a steel ball with a rubber mallet.

    Read the article

  • Hylafax: Encounter "No font metric information" when try to send a fax

    - by Chau Chee Yang
    I am using Hylafax 6.0.5 on Fedora 13 x86_64. As there are no rpm package available for Fedora 13, I use the source tar ball to install hylafax myself. Everything seems fine during compile and install. I try to send a fax with sendfax and encounter error: # sendfax -n -d <fax-number> /etc/passwd /usr/local/sbin/textfmt: No font metric information found for "Courier-Bold". Usage: /usr/local/sbin/textfmt [-1] [-2] [-B] [-c] [-D] [-f fontname] [-F fontdir(s)] [-m N] [-o #] [-p #] [-r] [-U] [-Ml=#,r=#,t=#,b=#] [-V #] files... >out.ps Default options: -f Courier -1 -p 11bp -o 0 Error converting document; command was "/usr/local/sbin/textfmt -B -f Courier-Bold -Ml=0.4in -p 11 -s default >'/tmp//sndfaxp5GdJ9' <'/etc/passwd'" It seems like there is problem with font problem. I have ghostscript-fonts installed too. I can't find hyla.conf in path /etc/hylafax. There is no /etc/hylafax path in my file system. All configuration files seems located in /var/spool/hylafax/etc. Please advice. Thank you.

    Read the article

  • "Options ExecCGI is off in this directory" When try to run Ruby code using mod_ruby

    - by Itay Moav
    I am on Ubuntu, Apache 2.2 Installed the fcgi via apt-get then removed it via apt-get remove. Installed mod-ruby configuration I added to Apache: LoadModule ruby_module /usr/lib/apache2/modules/mod_ruby.so RubyRequire apache/ruby-run <Directory /var/www> Options +ExecCGI </Directory> <Files *.rb> SetHandler ruby-object RubyHandler Apache::RubyRun.instance </Files> <Files *.rbx> SetHandler ruby-object RubyHandler Apache::RubyRun.instance </Files> I have a file in the www direcoty with puts 'baba' I have other files in that directory, all accessible via Apache. Test file has been chmod 777 In the browser I get 403. In Apache error log I get: [error] access to /var/www/t.rb failed for (null), reason: Options ExecCGI is off in this directory If I move this to a sub folder rubytest and modify the relevant config to be: <Directory /var/www/rubytest> Options +ExecCGI </Directory> and making sure the directory has 755 permissions on it, it just try to download the file, as if it does not recognize the postfix *.rb any more If I give directory and files 777 it fails: usr/lib/ruby/1.8/apache/ruby-run.rb:53: warning: Insecure world writable dir /var/www/rubytest in LOAD_PATH, mode 040777 [Tue May 24 19:39:58 2011] [error] mod_ruby: error in ruby [Tue May 24 19:39:58 2011] [error] mod_ruby: /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in load': loading from unsafe file /var/www/rubytest/t.rb (SecurityError) [Tue May 24 19:39:58 2011] [error] mod_ruby: from /usr/lib/ruby/1.8/apache/ruby-run.rb:53:in handler' BUT, IF I USE *.rbx it works like a charm...go figure.

    Read the article

  • Hylafax: Encounter "No font metric information" when try to send a fax

    - by Chau Chee Yang
    I am using Hylafax 6.0.5 on Fedora 13 x86_64. As there are no rpm package available for Fedora 13, I use the source tar ball to install hylafax myself. Everything seems fine during compile and install. I try to send a fax with sendfax and encounter error: # sendfax -n -d <fax-number> /etc/passwd /usr/local/sbin/textfmt: No font metric information found for "Courier-Bold". Usage: /usr/local/sbin/textfmt [-1] [-2] [-B] [-c] [-D] [-f fontname] [-F fontdir(s)] [-m N] [-o #] [-p #] [-r] [-U] [-Ml=#,r=#,t=#,b=#] [-V #] files... >out.ps Default options: -f Courier -1 -p 11bp -o 0 Error converting document; command was "/usr/local/sbin/textfmt -B -f Courier-Bold -Ml=0.4in -p 11 -s default >'/tmp//sndfaxp5GdJ9' <'/etc/passwd'" It seems like there is problem with font problem. I have ghostscript-fonts installed too. I can't find hyla.conf in path /etc/hylafax. There is no /etc/hylafax path in my file system. All configuration files seems located in /var/spool/hylafax/etc. Please advice. Thank you.

    Read the article

  • SkyDrive broken after upgrade to Windows 8.1: "This location can't be found, please try later"

    - by avo
    Upgrading from Windows 8 to Windows 8.1 via the Store upgrade path has screwed my SkyDrive. The C:\Users\<user name>\SkyDrive folder is empty (it only has single file desktop.ini). When I open the native (Store) SkyDrive app, I see "This location can't be found, please try later". I'm glad to still have my files alive online in my SkyDrive account. I tried disconneting from / reconnecting to my Microsoft Account with no luck. Anyone has an idea on how to fix this without reinstalling/refreshing Windows 8.1? From Event Viewer: Faulting application name: skydrive.exe, version: 6.3.9600.16412, time stamp: 0x5243d370 Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000 Exception code: 0x00000000 Fault offset: 0x0000000000000000 Faulting process ID: 0x4e8 Faulting application start time: 0x01cece256589c7ee Faulting application path: C:\Windows\System32\skydrive.exe Faulting module path: unknown Report ID: {...} Faulting package full name: Faulting package-relative application ID: Also: The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {C2F03A33-21F5-47FA-B4BB-156362A2F239} and APPID {316CDED5-E4AE-4B15-9113-7055D84DCC97} to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool. Never was a big fan of in-place upgrade anyway, but this time it was a machine which I use for work, with a lot of stuff already installed on it. Shouldn't have tried to upgrade it in the first place, but was convinced Windows 8.1 is a solid update. Another lesson learnt.

    Read the article

  • SVG doesn't work on subdomain - some browsers try to download rather than display

    - by John Catterfeld
    I have a site with a 'development' subdomain, which displays my SVG file exactly as intended. However when I copy it across to www, or any other subdomain (e.g. 'test') some browsers try to open the file in an external editor, therefore asking me to download the file rather than displaying it. For example: http://development.mysite.com/test.svg - works http://www.mysite.com/test.svg - doesn't work The SVG file: <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red" /> </svg> This happens in Firefox, Chrome and Safari, however IE9 and above display the file as intended. It is a Windows hosting, and I have <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> in my web.config file My hunch is that there must be some setting on the server which I need my hosting company to make. Can anyone suggest what might cause this issue?

    Read the article

  • Disposables, Using & Try/Catch Blocks

    - by Aren B
    Having a mental block today, need a hand verifying my logic isn't fubar'ed. Traditionally I would do file i/o similar to this: FileStream fs = null; // So it's visible in the finally block try { fs = File.Open("Foo.txt", FileMode.Open); /// Do Stuff } catch(IOException) { /// Handle Stuff } finally { if (fs != null) fs.Close(); } However, this isn't very elegant. Ideally I'd like to use the using block to dispose of the filestream when I'm done, however I am unsure about the synergy between using and try/catch. This is how i'd like to implement the above: try { using(FileStream fs = File.Open("Foo.txt", FileMode.Open)) { /// Do Stuff } } catch(Exception) { /// Handle Stuff } However, I'm worried that a premature exit (via thrown exception) from within the using block may not allow the using block to complete execution and clean up it's object. Am I just paranoid, or will this actually work the way I intend it to?

    Read the article

  • C# Compiler should give warning but doesn't?

    - by Cristi Diaconescu
    Someone on my team tried fixing a 'variable not used' warning in an empty catch clause. try { ... } catch (Exception ex) { } - gives a warning about ex not being used. So far, so good. The fix was something like this: try { ... } catch (Exception ex) { string s = ex.Message; } Seeing this, I thought "Just great, so now the compiler will complain about s not being used." But it doesn't! There are no warnings on that piece of code and I can't figure out why. Any ideas? PS. I know catch-all clauses that mute exceptions are a bad thing, but that's a different topic. I also know the initial warning is better removed by doing something like this, that's not the point either. try { ... } catch (Exception) { } or try { ... } catch { }

    Read the article

  • Python continue from the point where exception was thrown

    - by James Lin
    Hi is there a way to continue from the point where exception was thrown? eg I have the following psudo code unique code 1 unique code 2 unique code 3 if I want to ignore the exceptions of any of the unique code statements I will have to do it like this: try: #unique code 1 except: pass try: #unique code 2 except: pass try: #unique code 3 except: pass but this isn't elegant to me, and for the life of me I can't remember how I resolved this kind of problem last time... what I want to have is something like try: unique code 1 unique code 2 unique code 3 except: continue from last exception raised

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >