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

Java 8 method reference unhandled exception

I'm working on project with Java 8 and found one situation which I can't understand. I have code like this: void deleteEntity(Node node) throws SomeException { for...
Jon Skeet
people
quotationmark

If you look at the Consumer<T> interface, the accept method (which is what your method reference would effectively be using) isn't declared to throw any checked exceptions - therefore you can't use a method reference which is... more

people

Web Client timeout while downloading photos from external link

I am trying to download 10 photos from an external link e.g http://images.net/images/20159178574IMG_0843.jpg I am reading a text file on my drive and putting it on a list here is...
Jon Skeet
people
quotationmark

It looks like your problem is in the checkurl method, which doesn't dispose of the WebResponse that it gets - that means the connection pool associated with that host has effectively "lost" that connection until the WebResponse gets... more

people

Creating a Guid > conversion from VB to C#

I have the following code in VB.Net and I'm trying to convert it to C#. listContacts = ACT_FRAMEWORK.Contacts.GetContactsByID(Nothing, New Guid() {New Guid(ContactID)}) Below...
Jon Skeet
people
quotationmark

Guid.NewGuid is a method, and you're not calling that method from your VB code - you're calling the constructor accepting a string. You can call that same constructor in C#: // Using an array initializer for simplicity Guid[] test = { new... more

people

SQL server express, cannot read or write in C#

I have a code written that automatically adds and reads information from my SQL Server 2012 Express table, Logins. But it wont work, here is the code: private void...
Jon Skeet
people
quotationmark

it skips over [...] Presumably that's because there's no data to read, so myReader.Read() just returns false. it doesnt write the values i told it to. You don't actually tell it to write anything. You create a SqlCommand to... more

people

Dont understand the exception handeling in the case of changing interfaces as mentioned in Refactoring book by Fowler

I'm reading the Fowler book on Refactoring. In chapter 2 in the changing interfaces section. I don't understand this passage: There is one particular area with problems in...
Jon Skeet
people
quotationmark

Suppose you currently have: public interface Foo { void bar(); } You cannot later evolve this to: public interface Foo { void bar() throws SomeException; } (where SomeException is a checked exception) because code that... more

people

Parallel.Invoke does not wait for async methods to complete

I have an application that pulls a fair amount of data from different sources. A local database, a networked database, and a web query. Any of these can take a few seconds to...
Jon Skeet
people
quotationmark

It sounds like you really want something like: spinner.IsBusy = true; try { Task t1 = Task.Run(() => dataX = loadX()); Task t2 = Task.Run(() => dataY = loadY()); Task t3 = Task.Run(() => dataZ = loadZ()); await... more

people

NodaTime Errors after time switch

Yesterday Uruguay changed their clocks, and now I keep seeing exceptions when converting specific times for their timezone: ERROR Exception: - DateTime...
Jon Skeet
people
quotationmark

Yes, it is aware that it's an invalid local time - which is why when you specifically ask it to convert that local time into UTC, it throws an exception. It's roughly equivalent to calling Math.sqrt(-1). The InZoneStrictly call you're... more

people

How do I build a method that returns an action with a constrained parameter?

I have a common encapsulation I've been using in my controllers to handle alert message passing, exceptions, and error logging. Here is a simple version of it: private void...
Jon Skeet
people
quotationmark

I suspect you just want: public Action<T> Builder<T>() where T : DbContext Then you could call it as: Action<SpecificDbContext> actionHelper = Builder<SpecificDbContext>(); You don't need the type argument, as... more

people

Exception handling technique between class library and other projects

I'm little bit confused about handling exceptions within a hierarchy of methods. Let's say, I've a class Logger in a class library project. Please have a look on the following...
Jon Skeet
people
quotationmark

Do I actually need try.. catch in every method? No. In fact, it's harming your diagnostics by cutting off the stack trace - you won't be able to see the original full stack trace. You could fix that by just using: throw; instead... more

people

What is wrong with this object being capable of telling how many of its properties are not null/whitespace/empty?

I am trying to figure out why the following code throws a StackOverflowException (I am finally posting a StackoverflowException in SO!). Debugging seems to point out that the...
Jon Skeet
people
quotationmark

You have a property, which, when you execute the "get" accessor, finds all the properties and fetches their value. So it executes itself, recursively. If you only want string properties, you should check the property type before fetching... more

people