exception-handling

How do I hook up a HandlerExceptionResolver

微笑、不失礼 提交于 2019-12-19 10:56:08
问题 How do I hook up a HandlerExceptionResolver to catch exceptions and errors? web.xml <error-page> <error-code>500</error-code> <location>/support/500.jsp</location> </error-page> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/support/500.jsp</location> </error-page> <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/support/500.jsp</location> </error-page> 500.jsp //How do I get a stack trace or specific error message in here? 回答1: a

iOS CALayerInvalidGeometry

ε祈祈猫儿з 提交于 2019-12-19 10:49:08
问题 I have an app that is crashing, with this message: Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [2.74665e-34 nan]' here a more detailed exception message: CALayer position contains NaN: [2.74665e-34 nan] 2012-04-05 15:48:00.185 Infectious[28198:fb03] ( 0 CoreFoundation 0x0226803e __exceptionPreprocess + 206 1 libobjc.A.dylib 0x02820cd6 objc_exception_throw + 44 2 CoreFoundation 0x02210a48 +[NSException raise:format:arguments:] +

How to catch java.lang.NumberFormatException.forInputString Exception in Controller?

天涯浪子 提交于 2019-12-19 10:42:42
问题 I have a checkbox in my JSP page that accepts integer values: <form:checkbox path="somePath" value="2" /> Dangerous Checkbox <br /> If the user changes the value of the input to a String value, e.g.: <form:checkbox path="somePath" value="blah" /> Dangerous Checkbox <br /> the page will throw a NumberFormatException . How can I catch this in my Controller and show a meaningful message? 回答1: you can use JSTL's c:catch tag: <c:catch var ="numberFormatException"> <form:checkbox path="somePath"

Downloading large files, saved in Database

China☆狼群 提交于 2019-12-19 10:42:00
问题 We have a lot of files, saved as binary in our SQL Server database. I have made an .ashx file, that delivers these files, to the users. Unfortunately, when the files become rather large, it will fail, with the following error: Overflow or underflow in the arithmetic operation I assume it runs out of memory, as I load the binary into a byte[]. So, my question is, how can I make this functionality, read in chunks (maybe?), when it is from a database table? It also seems like Response

Should I catch all possible specific exceptions or just general Exception and wrap it in custom one?

江枫思渺然 提交于 2019-12-19 10:32:39
问题 Let's say I want to deserialize some XML file to a strongly typed object. In case this XML file can't be deserialized (for whatever reason) I would just create a default object and continue normal application workflow without showing any errors to the user. (actually this application is running as Windows service so there is no user for it... for example, imagine application trying to load config file and if fails then just use default config). My questions is how to create Deserialize()

Trying to get and print data from google search editbox but got InvalidElementStateException

邮差的信 提交于 2019-12-19 10:24:15
问题 I am trying to write a word in google search editbox and capture all the related list item and display it. But while doing so i got Got a exception org.openqa.selenium.InvalidElementStateException: Element is disabled and so may not be used for actions. I went through the same exception related question and according to them changed my code but none of them help. import java.util.List; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;

Reading data from specially formatted text file

允我心安 提交于 2019-12-19 10:22:37
问题 I am using this method, kindly suggested by Ashwini Chaudhary, to assign data to a dictionary from a text file that is in a specific format. keys = map(str.strip, next(f).split('Key\t')[1].split('\t')) words = map(str.strip, next(f).split('Word\t')[1].split('\t')) The text file has the row title followed by values, separated by a \t character. Example 1: Key a 1 b 2 c 3 d 4 Word as box cow dig How would I change my code not to read all the lines in a file, but only specific ones? Extra Lines

How can I reliably identify a specific error in PHP?

╄→гoц情女王★ 提交于 2019-12-19 10:12:13
问题 Because of PHP's unlink() not supporting exceptions natively, I'm making a wrapper function for it. It should throw a FileNotFoundException if, well, the given file could not be deleted because it doesn't exist. For this, I need to determine whether the error thrown by unlink() was caused by a missing file or something else. This is my test version for a custom delete function: public function deleteFile($path){ set_error_handler(function($errLevel, $errString){ debug($errLevel); debug(

Exception occurs while opening .xlsx file using Apache POI

无人久伴 提交于 2019-12-19 10:11:23
问题 I have been working on an android application in which i have to open .xls and .xlsx file for further implementation. In case of .xls everything is working fine but when i try to open .xls x file it gives me exception. below is my code Please help me solving these exception @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_code && resultCode == RESULT_OK && null != data) {

Exception occurs while opening .xlsx file using Apache POI

你说的曾经没有我的故事 提交于 2019-12-19 10:11:13
问题 I have been working on an android application in which i have to open .xls and .xlsx file for further implementation. In case of .xls everything is working fine but when i try to open .xls x file it gives me exception. below is my code Please help me solving these exception @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_code && resultCode == RESULT_OK && null != data) {