exception

WCF have exception pass to the client

夙愿已清 提交于 2020-01-12 14:34:07
问题 I have a service that may throw exceptions. I want to be able to catch the exceptions at the client. The main Exceptions I am interested in are DbUpdateException and InvalidOperationException . For the rest of the exceptions it is enough to know that an exception has been throws. How can I have exceptions caught in the client? 回答1: If your WCF service throws an exception, then by default it will come to the client as a FaultException . You can configure your service to include exception

Mysterious line in stack trace

喜夏-厌秋 提交于 2020-01-12 14:31:11
问题 While investigating a stack trace discrepancy when composing another answer, I came across a behavior I do not understand. Consider the following test program (this is as far down as I could narrow it): interface TestInterface <U> { void test (U u); } static class Test <T extends Test<T>> implements TestInterface<T> { // line 11 @Override public void test (T t) { throw new RuntimeException("My exception"); // line 13 } } static class TestA extends Test<TestA> { } static class TestB extends

How to verify that all own thrown runtime exceptions are covered in Javadoc?

你离开我真会死。 提交于 2020-01-12 14:03:07
问题 I throw a bunch of custom runtime exceptions in my code and I want to make sure that in all public methods, I document which runtime exception might be thrown ( by myself ) and why. This would be very hulpful since I'm maintaining a library which is used by many projects and I want it to be upfront and predictable regarding thrown (runtime) exceptions. Is there a compiler option, maven plugin, Intellij plugin or custom tool that can help me find missed throws clauses? With checked exceptions

How to jump back to the line of code that threw exception in Visual Studio 2010 debugger?

廉价感情. 提交于 2020-01-12 14:00:44
问题 Using the Visual Studio 2010 debugger, I am familiar with using the Call Stack window to see where the currently executing function was invoked from. I'm working with some applications that have rather large try blocks. Supposing that I pause execution of the code at a break point in the catch block, what is the simplest way to tell which line in the try block the exception was raised from? I do know that the "Stack Trace" includes details such as the line number, but is there an easier way,

How to jump back to the line of code that threw exception in Visual Studio 2010 debugger?

六月ゝ 毕业季﹏ 提交于 2020-01-12 14:00:35
问题 Using the Visual Studio 2010 debugger, I am familiar with using the Call Stack window to see where the currently executing function was invoked from. I'm working with some applications that have rather large try blocks. Supposing that I pause execution of the code at a break point in the catch block, what is the simplest way to tell which line in the try block the exception was raised from? I do know that the "Stack Trace" includes details such as the line number, but is there an easier way,

Python - test that succeeds when exception is not raised

℡╲_俬逩灬. 提交于 2020-01-12 13:41:32
问题 I know about unittest Python module. I know about assertRaises() method of TestCase class. I would like to write a test that succeeds when an exception is not raised. Any hints please? 回答1: The test runner will catch all exceptions you didn't assert would be raised. Thus: doStuff() self.assert_(True) This should work fine. You can leave out the self.assert_ call, since it doesn't really do anything. I like to put it there to document that I didn't forget an assertion. 回答2: def runTest(self):

Which Exception to throw when a method try to use a field that can be null? [duplicate]

拟墨画扇 提交于 2020-01-12 11:43:07
问题 This question already has answers here : Is there a built in .NET exception that indicates an illegal object state? (3 answers) Closed 2 years ago . I am actually working on a Framework development, which means require a really strong coding methodology. I am facing a problem where I do not know which System.Exception derivated class I need to throw. Basically the case is when I have a class with fields that can be optionnaly initialized by the constructor and that have methods using these

Catching exceptions out of 'stream()' or 'parallelStream()' loses correct values

会有一股神秘感。 提交于 2020-01-12 07:41:18
问题 In the following code, when catching NumberFormatException out of for iteration, the strings in appropriate form appearing in strList before the first bad one (i.e., "illegal_3" ) have been parsed successfully (i.e., "1" and "2" have been parsed as integers 1 and 2 ). public void testCaughtRuntimeExceptionOutOfIteration() { List<String> strList = Stream.of("1", "2", "illegal_3", "4", "illegal_5", "6").collect(Collectors.toList()); List<Integer> intList = new ArrayList<>(); try{ for (String

Catch all type exceptions programming Android

拈花ヽ惹草 提交于 2020-01-12 06:37:13
问题 I'm developing an application for Android OS. Since this is my first application, I think I've committed some programming mistakes cause I hardly can trace bugs back to their causes. Thus, I was guessing, while i'm trying to fix bugs, is there a way to catch ALL types of exception in my entire activity lifecycle with one try-catch? That would be awesome, i'm getting bored watching my galaxy S say :"Sorry the application App has stopped unexpectly" :( 回答1: I really, really don't recommend this

In a Java debugger, how to ignore exceptions never passing through my code

陌路散爱 提交于 2020-01-12 05:42:05
问题 I'm currently using IntelliJ IDEA for Java development, but I'm also interested in answers targeting other IDEs or general concepts for debugging Java code. Because this is a feature I've missed in a number of IDEs, I'm unsure if I've missed a workflow concept when transferring my debug habits from other languages. Let's say I'm writing some code in myapp.* while using framework classes from somelib.* . A typical stack trace may start in either package and may switch several times between