try-catch Questions

4

Solved

const errorTest = async() => { const result = await $.get("http://dataa.fixer.io/api/latest?access_key=9790286e305d82fbde77cc1948cf847c&format=1"); return result; } try { erro...
Brainsick asked 23/6, 2021 at 15:2

4

Solved

I am new at Java and am experiencing a bit of a problem with throwing exceptions. Namely, why is this incorrect public static void divide(double x, double y) { if (y == 0){ throw new Exception(&q...
Alignment asked 23/11, 2013 at 0:32

7

Solved

I've got a piece of code similar to this: import sys def func1(): func2() def func2(): raise Exception('test error') def main(): err = None try: func1() except: err = sys.exc_info()[1] ...
Aalesund asked 28/1, 2011 at 5:42

8

Everything I have ever been told is that go to's are evil and stay away from them, but I think they may help me here (?). I would like to provide the user an option to restart the application when ...
Noctilucent asked 17/3, 2011 at 15:32

7

Solved

Trying to get the try/except statement working but having problems. This code will take a txt file and copy the file that is in location row 0 to location of row 1. It works however if i change one...
Biafra asked 22/1, 2013 at 13:54

18

Solved

I'm looking at the article C# - Data Transfer Object on serializable DTOs. The article includes this piece of code: public static string SerializeDTO(DTO dto) { try { XmlSerializer xmlSer = new...
Minus asked 19/5, 2009 at 7:56

2

Solved

I'm applying a map to a dictionary that has a try in it. I'd like to skip the iteration if the mapped item is invalid. For example: func doSomething<T: MyType>() -> [T] dictionaries.map...
Dispassion asked 29/3, 2016 at 19:26

3

Solved

I am using Angular 7 where I am trying to catch an error thrown because a value returned by the external api had null values where I expected values. I can't seem to figure out what I am supposed...
Logwood asked 28/3, 2019 at 14:41

13

Solved

I have a number of functions which either return something or throw an error. In a main function, I call each of these, and would like to return the value returned by each function, or go on to the...
Proceeds asked 23/4, 2011 at 12:15

5

Solved

I was using HashMap before like public Map<SocketChannel, UserProfile> clients = new HashMap<SocketChannel, UserProfile>(); now I've switched to ConcurrentHashMap to avoid synchron...
Kalamazoo asked 16/9, 2010 at 0:57

8

Solved

Is it possible to handle multiple different errors at once instead of individually in Rust without using additional functions? In short: what is the Rust equivalent to a Try-Catch statement? A simi...
Spectroscope asked 19/4, 2019 at 1:34

4

Solved

I know the best way to prevent system crashes is catching all possible exception in different methods. So I use try catch blocks every where in my code. However as you know sometimes you forget to ...
Aerification asked 26/8, 2015 at 14:16

2

I'm trying to put a simple log into my script. This log should tell me where is the error and as much as possible info needed to repair the script. I've put print to file str(e) into each except ...
Filly asked 26/7, 2015 at 12:20

3

I am trying to use Swift 2.0 try-catch. I originally had the following code override func viewDidLoad() { var obj : Object?; Hi( obj ); } But it procdues an error func Hi( open : Open? ) -&g...
Quach asked 10/7, 2015 at 7:32

3

Solved

When retrieving the h1 title using rvest, I sometimes run into 404 pages. This stop the process and returns this error. Error in open.connection(x, "rb") : HTTP error 404. See the example bel...
Lynelllynelle asked 30/6, 2016 at 4:35

1

Solved

I am attempting to learn and create exceptions in C++, however only one catch is being used instead of the other for an exception from cin using ios::failbit. The code below is just using integer d...
Prothorax asked 27/5, 2023 at 7:41

7

Solved

How do I make it so the code runs only if there was no exception thrown? With finally code runs whether there was an exception or not. try { //do something } catch (Exception e) {} //do somethin...
Brandon asked 3/5, 2015 at 21:10

19

Solved

I want to catch and log exceptions without exiting, e.g., try: do_stuff() except Exception as err: print(Exception, err) # I want to print the entire traceback here, # not just the exception na...
Ionopause asked 13/9, 2010 at 17:3

6

I have a statement inside a try/catch block, but the exception is not getting caught. Can anyone explain? Exception Details: System.NullReferenceException: Object reference not set to an insta...
Lindie asked 27/10, 2009 at 12:21

6

Solved

I want to write code using tryCatch to deal with errors downloading data from the web. url <- c( "http://stat.ethz.ch/R-manual/R-devel/library/base/html/connections.html", "http...
Lineament asked 30/8, 2012 at 9:27

10

Solved

I have a recursive call to a method that throws a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught. Does the stack overflow exception be...
Shaeffer asked 21/10, 2009 at 7:15

20

Solved

I do not currently have this issue, but you never know, and thought experiments are always fun. Ignoring the obvious problems that you would have to have with your architecture to even be attempti...
Eyra asked 22/9, 2008 at 19:58

3

Solved

I'm trying to include a file, and catch it if the file does not exist / can not be opened. I would have thought that a simple try/catch statement would have worked but PHP seems to completely ignor...
Towage asked 4/11, 2011 at 20:38

11

Solved

I've a piece of code: using (StreamReader stream = new StreamReader(file.OpenRead(), Encoding)) { char[] buffer = new char[chunksize]; while (stream.Peek() >= 0) { int readCount = stream.Rea...
Thereof asked 21/2, 2011 at 14:33

11

Solved

In Java, I want to do something like this: try { ... } catch (/* code to catch IllegalArgumentException, SecurityException, IllegalAccessException, and NoSuchFieldException at the same time */...
Aronoff asked 16/8, 2010 at 18:7

© 2022 - 2025 — McMap. All rights reserved.