exception-handling

Question about Exceptions

眉间皱痕 提交于 2019-12-09 03:23:48
问题 I was just playing around with exceptions in the visual studio and with the above code I was expecting that since my exception specification doesn't mention anything the bad_exception should have been thrown. But what actually happens is the exception gets caught by the appropriate handler. Why so? Am i missing some setting or something in the IDE? While i got stuck at above mentioned, Actually I was trying to find answer to the question,If i have a exception blank specification then what

.NET Remoting Exception not handled Client-Side

吃可爱长大的小学妹 提交于 2019-12-09 03:21:37
问题 I checked the rest of the remoting questions, and this specific case did not seem to be addressed. I have a .NET Remoting server/client set up. On the server side I have an object with a method that can throw an exception, and a client which will try to call that method. Server: public bool MyEquals(Guid myGuid, string a, string b) { if (CheckAuthentication(myGuid)) { logger.Debug("Request for \"" + a + "\".Equals(\"" + b + "\")"); return a.Equals(b); } else { throw new

DebuggerStepThrough, DebuggerHidden don't work in an async-await method

别说谁变了你拦得住时间么 提交于 2019-12-09 02:46:35
问题 When you turn on the "Break when an exception is thrown" feature in the Visual Studio debugger it breaks everywhere for selected exception types. The way to tell it not to break in a specific method is to decorate these methods with DebuggerStepThrough attribute (or DebuggerHidden). This, evidently , doesn't work for an async method for some reason. Here's a snippet that reproduces the issue. The debugger will break inside the TestAsync even though it's marked with the attributes and it will

How to map RuntimeExceptions in Java streams to “recover” from invalid stream elements

家住魔仙堡 提交于 2019-12-08 23:32:39
问题 Imagine I'm building a library, that will receive a Stream of Integers, and all the library code needs to do is return a stream of Strings with the string representation of the number. public Stream<String> convertToString(Stream<Integer> input) { return input.map(n -> String.valueOf(n)); } However, imagine someone decides to invoke my function with the following code: Stream<Integer> input = Stream.of(1,2,3) .map(n -> { if (n %3 ) { throw new RuntimeException("3s are not welcome here!"); }

How to implement top level exception handling?

自古美人都是妖i 提交于 2019-12-08 23:29:32
问题 I recently had to develop an additional module for an existing service developed by a colleague. He had placed a try/catch block in the main working function for catching all unhadled exceptions that bubbled up to this level, logging them together with stack trace info etc: try { // do main work } catch(Exception ex) { // log exception info } While this makes the program very stable (as in 'unlikely to crash'), I hate it because when I am testing my code, I do not see the exceptions caused by

Is there any workaround to rethrow an exception and preserve the stacktrace in Javascript?

半世苍凉 提交于 2019-12-08 22:00:32
问题 I know that Chrome has a known bug not preserving the stacktrace when rethrowing an exception in Javascript. I have the following code running in Chrome: try { try { runCodeThatMayThrowAnException(); } catch (e) { // I'm handing the exception here (displaying a nice message or whatever) // Now I want to rethrow the exception throw (e); } } catch (e) { // The stacktrace was lost here :( } Is there any way to keep the stacktrace? A jQuery plug-in maybe? Any workaround or ideas? 回答1: In the

How to handle Task.Factory.StartNew exception?

試著忘記壹切 提交于 2019-12-08 20:18:34
问题 I have some strange problem here. Exception thrown by Task always not handled independently how can I try to handle it. I try this: http://msdn.microsoft.com/en-us/library/dd997415%28v=vs.110%29.aspx private class MyCustomException : Exception { public MyCustomException(String message) : base(message) { } } public static void Main() { var task1 = Task.Factory.StartNew(() => { throw new MyCustomException("I'm bad, but not too bad!"); }); try { task1.Wait(); } catch (AggregateException ae) { //

Android Socket Exception “socket is closed”

白昼怎懂夜的黑 提交于 2019-12-08 19:36:29
问题 When I try to run a test composed of an echo server and an android client with the following code, I always get the exception msg "socket is closed". This code can simply send msg to server, and receive msg from server, but if you want to do both at the same time, it just doesn't work... I am very curious why it will lead to this kind of problem, and how should I fix it if I want it to be able to first send msg to echo server and then receive msg from echo server? // Server IP address

How do appDomain provide Isolation

旧时模样 提交于 2019-12-08 19:33:29
In my window forms application, I create a Appdomain say sandBox. In this sandbox i excute some code Say TestMethod from TestAppdomain Class. This class is in Test.dll which is not loaded in the current appdomain (Default appdomain). Now while executing TestMethod some exception occurs, then I want the sandbox domain to be unloaded and since AppDOmain provide Isolotion my Default Appdomain shoud not be affected. But As i read over the internet i guess this is not possible.But could some one give me some pointer on how to achive it. Thanks in Advance Vikram David Nelson Yes this is certainly

How can I handle the exception which throws on an external dll?

女生的网名这么多〃 提交于 2019-12-08 19:08:57
问题 I have developed a project which uses an external dll as FTPServer, I have created the FTP Server on my project like this: private ClsFTPServer _ClsFTPServer; _ClsFTPServer = new ClsFTPServer(FTPUserName, FTPPassword, FTPPath); The Code above creates an instance of FTP server class, the class starts the FTPserver on it's constructor, it works fine independently as a module while the clients send their request correctly, but when an incorrect request comes to FTP server it throws an exception