exception-handling tag

15 questions


1 answers
162 views
0
Why is it possible to do throw null; when handling exceptions" in Java?

public class WhatTheShoot { public static void main(String args[]){ try { throw null; } } catch (Exception e){ System.out.println(e instanceof NullPointerException); System.out.println(e instance...


1 answers
154 views
0
Why does Python write "else" for try-else?

When should I write else in try- statement?There seems to be no difference between codes 1, 2, and 3 below If the else statement is executed when no error occurs in the try statement,Can't you just no...


1 answers
142 views
0
What are the advantages of goto in iterations/functions?

At school, I was taught not to use Goto under any circumstancesLooking at libavcodec, surprisingly, there are still many people who use goto. What are the advantages of goto in iterations/functions?Yo...


2 answers
126 views
0
C# Exception VS Return Code

Question 1 public class foo { } public foo SomeFooNULL() { var newFoo = new foo(); if(null == newFoo) { return null; } return newFoo; } public foo SomeFooException() { var newFoo = new foo(); ...


1 answers
98 views
0
Can I change it to if or for statement instead of Python exception?

while True: try: driver.find_element_by_id('').click() break except: try: scroll() driver.find_element_by_id('').click() break except: scroll()I want to scroll until I find the...


1 answers
104 views
0
This is a question regarding Begin-Rescue-Ensure handling exception to Ruby

Is ensure in Ruby = finally the same in C#?I don't know exactly when sense will run, so I don't know when to close the file.file = File.open(myFile.txt, w)begin file << #{content} \nrescue #hand...

2 years ago

1 answers
124 views
0
Do I have to make an exception for all the blocks?

In the case of reducing the exception, it is safe to deal with exceptions.Then should I make an exception by using all those blocks as a try-catch?Doesn't that make the code too messy?


1 answers
88 views
0
Is it possible to ignore exceptions in exception handling?

I just want to ignore some code and keep running if there's an exceptionIn this case, how should I try-except?See if I'm righttry : shutil.rmtree ( path )except : pass


1 answers
125 views
0
I'm trying to catch all the exceptions at once

try: #What kind of chords?except IOError: #Exception ProcessingIt's not about every one of the exceptions, but just catch all the exceptions at onceI'd like to take care of it. Is it possible?


1 answers
112 views
0
How do I deliberately make a specific exception in a unit test?

We need to do a unit test for the exceptionIs there a way to deliberately cause specific exceptions such as EOFError and ZeroDivisionError?

- 1 - »

© 2024 OneMinuteCode. All rights reserved.