exception-handling

Is it good to catch a more general type of Exception?

老子叫甜甜 提交于 2019-12-19 03:38:07
问题 If we are to catch specific forms of IOException , or any other kind as a matter of fact, and we only try and catch a couple (and define definitive outputs for them) say FileNotFoundException ZipException should we always trail it off and cover all bases with a catch(IOException e){ e.printStackTrace(); } and then possibly go even further and catch Exception e , or is this a complete waste of time? 回答1: Generally, you only want to catch and handle exceptions you can do something with at a low

Java Heap Memory error

女生的网名这么多〃 提交于 2019-12-19 03:31:07
问题 I am getting this error: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at com.mysql.jdbc.MysqlIO.nextRowFast(MysqlIO.java:1585) at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1409) at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2886) at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:476) at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2581) at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1757) at com.mysql.jdbc.MysqlIO

JavaScript list of exceptions

寵の児 提交于 2019-12-19 03:24:39
问题 This time I don't have any problem but just for curiosity I want to know how many exception are there in JavaScript. For example I am using following code: <script type="text/javascript"> var x; try{ x = 1 / 0; alert(x); // output: Infinity. FYI: JavaScript has Infinity property and it's value is 1.7976931348623157E+10308 alert(funCreate()); } catch(obj) { alert(obj.fileName); alert(obj.lineNumber); alert(obj.message); // output: funCreate is not defined alert(obj.name); // output:

How does JVM handles RuntimeException(s)

北城以北 提交于 2019-12-19 03:23:07
问题 While creating custom exceptions, If we want to create a checked Exception we extend the Exception class and for unchecked exception we extend the RuntimeException class. My question is, how JVM handles subClasses of RuntimeException and Exception differently when they all are sub classes of the Exception class. 回答1: It doesn't. The only difference is in requirements enforced by the compiler. 回答2: You are mistaken that the JVM handles the exceptions differently, but your question is still

C# Exceptions only caught when debugging? [duplicate]

情到浓时终转凉″ 提交于 2019-12-19 03:19:16
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Exception handling problem in release mode I suspect there is a perfectly simple explanation for this, but I can't seem to find it. When my WinForms C# 4.0 application loads itself in the Program.cs file, the entire Main() function has inside it a try/catch statement. I have written a little exception wrapper which behaves quite similarly to the vanilla .net "uncaught exception" box, except it provides a bit

How can I re-throw an exception in a lambda block as from the outer block?

南楼画角 提交于 2019-12-19 03:15:12
问题 With following code, void key(Key) throws SomeCheckedException { } void supplier(Supplier<Key> s) throws SomeCheckedException { ofNullable(s).ifPresent(s -> { // | try { // | key(s.get()); // | } catch (final SomeCheckedException sce) { // | // sce is coming from key() method // | // How can I throw sce for outer method? // --/ } }); } How can I throw sce as if the method( supplier ) method is throwing it? Please note that above code is just an example. I need the key(s.get()) to be inside a

OpenGL suppresses exceptions in MFC dialog-based application

╄→гoц情女王★ 提交于 2019-12-19 03:13:33
问题 I have an MFC-driven dialog-based application created with MSVS2005. Here is my problem step by step. I have button on my dialog and corresponding click-handler with code like this: int* i = 0; *i = 3; I'm running debug version of program and when I click on the button, Visual Studio catches focus and alerts "Access violation writing location" exception, program cannot recover from the error and all I can do is to stop debugging. And this is the right behavior. Now I add some OpenGL

How to use boost::error_info correctly?

£可爱£侵袭症+ 提交于 2019-12-18 19:18:23
问题 I'm trying to following the examples on this page: http://www.boost.org/doc/libs/1_40_0/libs/exception/doc/motivation.html The minute I try the following line: throw file_read_error() << errno_code(errno); I get an error: error C2440: '<function-style-cast>' : cannot convert from 'int' to 'errno_code' How do I get this to work?? Ideally I want to create something like this: typedef boost::error_info<struct tag_HRESULTErrorInfo, HRESULT> HRESULTErrorInfo; But I can't even get the first

Disable exception chaining in python 3

五迷三道 提交于 2019-12-18 19:08:10
问题 There is a new feature that was introduced in python3 - exception chaining. For some reasons I need to disable it for certain exceptions in my code. Here is sample code: try: print(10/0) except ZeroDivisionError as e: sys.exc_info() raise AssertionError(str(e)) what I see: Traceback (most recent call last): File "draft.py", line 19, in main print(10/0) ZeroDivisionError: division by zero During handling of the above exception, another exception occurred: Traceback (most recent call last):

Could not find any resources appropriate for the specified culture or the neutral culture

旧巷老猫 提交于 2019-12-18 18:55:20
问题 I have created an assembly and later renamed it. Then I started getting runtime errors when calling: toolsMenuName = resourceManager.GetString(resourceName); The resourceName variable is "enTools" at runtime. Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Jfc.TFSAddIn.CommandBar.resources" was correctly embedded or linked into assembly "Jfc.TFSAddIn" at compile time, or that all the satellite assemblies required are loadable and fully