exception-handling

Catching IllegalArgumentException?

梦想与她 提交于 2021-02-20 04:11:28
问题 I am having a little bit of a problem here. I am trying to figure out how to catch the IllegalArgumentException. For my program, if the user enters a negative integer, the program should catch the IllegalArgumentException and ask the user if he/she wants to try again. But when the exception is thrown, it doesn't give that option. It just terminates. I tried to use the try and catch method but it doesn't work for me. How do I catch this particular exception to continue to run instead of

Catching IllegalArgumentException?

风格不统一 提交于 2021-02-20 04:11:10
问题 I am having a little bit of a problem here. I am trying to figure out how to catch the IllegalArgumentException. For my program, if the user enters a negative integer, the program should catch the IllegalArgumentException and ask the user if he/she wants to try again. But when the exception is thrown, it doesn't give that option. It just terminates. I tried to use the try and catch method but it doesn't work for me. How do I catch this particular exception to continue to run instead of

Catching IllegalArgumentException?

筅森魡賤 提交于 2021-02-20 04:09:12
问题 I am having a little bit of a problem here. I am trying to figure out how to catch the IllegalArgumentException. For my program, if the user enters a negative integer, the program should catch the IllegalArgumentException and ask the user if he/she wants to try again. But when the exception is thrown, it doesn't give that option. It just terminates. I tried to use the try and catch method but it doesn't work for me. How do I catch this particular exception to continue to run instead of

Handling multiple exceptions from async parallel tasks

丶灬走出姿态 提交于 2021-02-18 22:13:27
问题 Problem Several tasks are run in parallel, and all, none, or any of them might throw exceptions. When all the tasks have finalized, all the exceptions that might have happened must be reported (via log, email, console output.... whatever). Expected behavior I can build all the tasks via linq with async lambdas, and then await for them running in parallel with Task.WhenAll(tasks) . Then I can catch an AggregateException and report each of the individual inner exceptions. Actual behavior An

Handling multiple exceptions from async parallel tasks

社会主义新天地 提交于 2021-02-18 22:13:05
问题 Problem Several tasks are run in parallel, and all, none, or any of them might throw exceptions. When all the tasks have finalized, all the exceptions that might have happened must be reported (via log, email, console output.... whatever). Expected behavior I can build all the tasks via linq with async lambdas, and then await for them running in parallel with Task.WhenAll(tasks) . Then I can catch an AggregateException and report each of the individual inner exceptions. Actual behavior An

Python 2.7 try and except ValueError

让人想犯罪 __ 提交于 2021-02-17 21:25:29
问题 I query user input which is expected to be an int by using int(raw_input(...)) However when the user doesn't enter an integer, i.e. just hits return, I get a ValueError. def inputValue(inputMatrix, rangeRows, rangeCols, defaultValue, playerValue): rowPos = int(raw_input("Please enter the row, 0 indexed.")) colPos = int(raw_input("Please enter the column, 0 indexed.")) while True: #Test if valid row col position and position does not have default value if rangeRows.count(rowPos) == 1 and

Python 2.7 try and except ValueError

自古美人都是妖i 提交于 2021-02-17 21:23:09
问题 I query user input which is expected to be an int by using int(raw_input(...)) However when the user doesn't enter an integer, i.e. just hits return, I get a ValueError. def inputValue(inputMatrix, rangeRows, rangeCols, defaultValue, playerValue): rowPos = int(raw_input("Please enter the row, 0 indexed.")) colPos = int(raw_input("Please enter the column, 0 indexed.")) while True: #Test if valid row col position and position does not have default value if rangeRows.count(rowPos) == 1 and

Python 2.7 try and except ValueError

让人想犯罪 __ 提交于 2021-02-17 21:23:08
问题 I query user input which is expected to be an int by using int(raw_input(...)) However when the user doesn't enter an integer, i.e. just hits return, I get a ValueError. def inputValue(inputMatrix, rangeRows, rangeCols, defaultValue, playerValue): rowPos = int(raw_input("Please enter the row, 0 indexed.")) colPos = int(raw_input("Please enter the column, 0 indexed.")) while True: #Test if valid row col position and position does not have default value if rangeRows.count(rowPos) == 1 and

How do I make Visual Studio 2015 ignore handled exceptions?

僤鯓⒐⒋嵵緔 提交于 2021-02-17 07:05:28
问题 So I have this chunk of code, and when debugging in Visual Studio, it's breaking even though the exception is handled in my code. I only want it to break when this exception is unhandled by my code. The Exceptions Settings box only has an option to continue on unhandled exceptions in user code, but that's not acceptable because I still need it to break if it's unhandled. I've seen screenshots of previous versions of VS that had an option for this. Is this a VS 2015 bug or did microsoft remove

How to get IO error messages when creating a file in C++?

走远了吗. 提交于 2021-02-16 14:26:08
问题 One of the ancient anti-pattern is people checking error status and then returning fairly useless messages like "operation failed" instead of "operation failed because ...". I want C++ file I/O operations to fail with exception and get the error message on why it failed. Specifically I want ofstream object to raise exception when file creation fails and get bit more useful message such as "permission denied" or "No file or path". This is trivial to do in languages such as C# or Java or Python