exception-handling

PHP - Converting all Errors to Exceptions - Good or Bad?

試著忘記壹切 提交于 2019-12-21 07:04:08
问题 I was wondering if it's considered a bad practice to globally convert all PHP Errors to Exceptions. Something like the following would be used: function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); return false; } I suppose the assumption is that you can just start using "try/catch" around certain pieces of code that would normally throw Errors. If it's not a case of Good/Bad, what are some of the Gotchas

Unable to add service in WcfTestClient when copy to a different machine

南笙酒味 提交于 2019-12-21 07:02:42
问题 I'd like to run WcfTestClient (one that's included with VS2012) on a different machine without installing VS2012. Is this possible? On the machine I've installed .NET 4.5 but when I try to add web services it gives me the following stack trace: ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Tools.Common.SdkPathUtility.GetRegistryValue(String registryPath, String registryValueName) at Microsoft

Prevent stack trace logging for custom exception in Spring Boot application

亡梦爱人 提交于 2019-12-21 06:59:46
问题 Is there a way in Spring Boot (mvc) to log a custom exception and throw it without its stack trace being visible in the log file? But for any other exception still see the stack trace. Long explanation: I am using spring boot to create a simple rest service. I like that for a custom exceptions there is no stack trace in the logs by default and json response is created with the basic exception details (status, error, message). The problem is that it also creates no log entry at all, therefore

Is it possible to do Vectored Strctured exception handling in c#?

删除回忆录丶 提交于 2019-12-21 06:25:19
问题 As far as i know, when a first chance exception occurs, the debugger is notified(if any) and then if still unhandled, the system searches for the nearest frame based exception handler in the stack if any. I was reading this link when I came to know about vectored exception handling. Question1) I was wondering if there is any way we can do that in managed code? Question2) I think that any try{}catch{} is a frame based handler but what happens when we register a handle at certain events like

Bad idea to chain exceptions with RMI?

霸气de小男生 提交于 2019-12-21 06:05:25
问题 Is it a bad idea to use exception chaining when throwing RemoteExceptions? We have an RMI server that does something like this: public Object doSomething() throws RemoteException { try { return getData(); } catch (CustomException ex) { throw new RemoteException(ex); } } I'm getting UnmarshallException caused by a ClassNotFoundException in my client. On the plus side, it turns out that CustomException itself IS exported. Unfortunately, another exception deep inside this guy is NOT exported,

My PowerShell exceptions aren't being caught

六月ゝ 毕业季﹏ 提交于 2019-12-21 05:32:16
问题 Powershell v2: try { Remove-Item C:\hiberfil.sys -ErrorAction Stop } catch [System.IO.IOException] { "problem" } catch [System.Exception] { "other" } I'm using the hibernation file as an example, of course. There's actually another file that I expect I may not have permission to delete sometimes, and I want to catch this exceptional situation. Output: output and yet $error[0] | fl * -Force outputs System.IO.IOException: Not Enough permission to perform operation. Problem: I don't see why I'm

How to send android app logs to remote server?

不羁的心 提交于 2019-12-21 05:32:13
问题 In my application, I want to send logs in case of crash to remote server. I have added try-catch block and in catch I'm sending logs to server. I want to know what all exceptions should I catch. I need logs in case of every crash so that I can fix it. Would it be a good practice to catch all Exceptions? Thanks in advance. 回答1: Here is a summarized list of suggestions I curated from other great answers: Catch all unhandled exceptions . Create an ExceptionHandler that implements java.lang

I get a segmentation fault instead of an exception

两盒软妹~` 提交于 2019-12-21 04:51:14
问题 In the following code, at the first iteration I get an exception, and at the second one I get a segmentation fault with no error message printed. It seems the exception is not caught: int i = 0; while(i++ < 10) { try { cout << "Iteration: " << i << endl; // Code... cout << "OK" << endl; } catch(...) { cerr << "Error message" << endl; continue; } } Output: Iteration 1 Error message Iteration 2 Segmentation fault Is it normal, or there is something really wrong going on? In case it should be

Will a java exception terminate the whole java application?

折月煮酒 提交于 2019-12-21 04:40:32
问题 I used to think that when an exception happened, the whole java application will be terminated. For example, I write a test function to test my idea. public void test(){ File fileDir=new File(sourceDataDir); if(fileDir.exists()){ File[] files = fileDir.listFiles(); for(int index=0 ; index<files.length ; index++){ System.out.println("index = "+index); File file = files[index]; if(index == 1)//delete a file to cause a FileNotFoundException file.delete(); try { BufferedReader in = new

What happens with set_error_handler() on PHP7 now that all errors are exceptions?

天大地大妈咪最大 提交于 2019-12-21 04:39:18
问题 On PHP5 it makes a whole lot of sense having both set_exception_handler() and set_error_handler() defined. However, on PHP7 all (most?) errors are now exceptions. So, what's the point on defining both handlers, if even errors would pass by the exception handler instead? I see there's a note on PHP7 new Error class in the exception handler doc, but there's no reference to the fact there's no plain errors anymore, but Throwable s, in the error handler function. Since PHP 7, most errors are