You searched for exceptions. We found 168 results in 0.054 seconds.

If I have a class called 'exceptions' and it has only static classes, is this breaking Java standards?

If I have class like this, which is essentially just a package object, is it breaking standards to have it follow the package naming conventions? I thought I remembered reading...
Jon Skeet
people
quotationmark

If I have class like this, which is essentially just a package object, is it breaking standards to have it follow the package naming conventions? Yes. It's not a package, it's a class, so it should follow class naming conventions...... more

people

What to do with never happening, useless exceptions?

I have this code: HttpPut put = new HttpPut(url); try { put.setEntity(new StringEntity(body, "UTF-8")); } catch (UnsupportedEncodingException e1) { // That would really...
Jon Skeet
people
quotationmark

I would throw some kind of RuntimeException which indicates that you think this really should never happen. That way: If it ever does happen, you find out about it rather than swallowing it and continuing Your expectation that it really... more

people

SimpleDateFormat: unexpected results and unexpected parse exceptions

I'm having huge difficulties with simple date format. First of all, I know not all tutorials on all sites are actually good, but the fact that all non trivial formats (not...
Jon Skeet
people
quotationmark

And I don't understand why something as simple as: (code snipped) Throws a parse exception. My guess is that it's tripping up over Jun which may not be a valid month abbreviation in your system default locale. I suggest you... more

people

await Task.WhenAll(tasks) Exception Handling, log all exceptions from the tasks

I am trying to figure out how to report all exceptions thrown by a list of tasks from the code below. The basic idea of this code snippet is: The user sends a request to the...
Jon Skeet
people
quotationmark

You've fallen foul of lazy evaluation - the result of Select will create a new set of tasks each time you iterate over it. You can fix this just by calling ToList(): var tasks = _factory.CreateMessage(settings) ... more

people

I am borrowing a method that catches 10 kinds of exceptions but does nothing with them. Can I replace them with just (Exception e)

Im borrowing this method I found on the internet: private static int getExifOrientation(String src) throws IOException { int orientation = 1; try { /* *...
Jon Skeet
people
quotationmark

To sum up: does "catch Exception e" catch all kinds of exceptions or should each one be named individually It catches everything of type Exception or a subclass. It will not catch other Throwables, e.g. Error. But given that all the... more

people

Where Debug/Exceptions menu item gone in VS 2015?

Recently I noticed this menu item is gone in my new VS 2015. Is a feature, or just me?
Jon Skeet
people
quotationmark

It's still there, just moved to be its own dockable window instead of a dialog: Debug => Windows => Exception Settings more

people

File Parse code gives me exceptions instead of a number and file writing code gives writes gibberish instead of a number

This code reads a notepad file this notepad file has the number 10 on it it returns a gibberish letter for some reason instead of 10 I think it is the ascii code but i do not know...
Jon Skeet
people
quotationmark

This line doesn't do what you expect: output.write(number); It's calling write on a BufferedWriter, so you should consult the documentation... at which point you find you're calling this method. public void write(int c) throws... more

people

How can I test the set of my method exceptions through one test only?

NUnit 3, VS2015 I want to test exception types of my method through TestCase attributes using, but NUnit3TestAdapter doesn't see my test in VS2015 (my class is...
Jon Skeet
people
quotationmark

I suspect the problem is that the test method is generic. Instead of using the generic Assert.Throws<T>, use the overload that accepts an exception type: [TestCase(null, typeof(ArgumentNullException))] [TestCase("",... more

people

How to read a Stream one by one?

The Java Stream.forEach function has the serious limitation that it's impossible for its consumer to throw checked exceptions. As such, I would like to access a Stream's elements...
Jon Skeet
people
quotationmark

To iterate over a stream element-by-element, just call the iterator() method: Iterator<String> iterator = stream.iterator(); while (iterator.hasNext()) { String element = iterator.next(); // Use element } It's not clear to... more

people

Does async Task method never throw?

It appears that an async method always captures its exceptions into a Task that the method returns including those thrown before the first await". In other words the following...
Jon Skeet
people
quotationmark

Is this behavior of async methods part of the language spec Yes it is. From section 10.15.1 of the C# 5 specification: If the function body terminates as the result of an uncaught exception (ยง8.9.5) the exception is recorded in... more

people