Summary: Is there a more elegant solution to the code block below? Details: I send an HTTP request to a server with WebRequest. The server might respond with 404 or another HTTP error code. It seems that the only way to handle these HTTP error codes is using try-catch, as in my code below. I thought error handling like this should only be for 'proper' errors, whereas I consider the HTTP error codes to be legitimate responses. For example, I'd (a) like to do a Select Case on myWebResponse.StatusCode (which might be 200, 202, 404, or something else), and (b) I don't want to have to explicitly re-throw or handle other WebExceptions that might occur; those should just go to whatever error handling happens to be in place at a higher level. My solution works, but would be neater if I could replace the whole block below with something like myWebResponse=myWebRequest.GetResponse(AcceptHttpErrorStatuses:=True). Is something like this possible, or does everyone use similar try-catch solutions? I suppose I should write a function that does the try-catch. Do others agree that the try-catch approach is ugly, or do you think exception handling is always appropriate for HTTP error codes? Try     myWebResponse= myWebRequest.GetResponse() Catch ex As WebException     If Not ex.Response Is Nothing Then         myWebResponse = ex.Response 'So that I can later do Select Case myWebResponse.StatusCode.     Else         Throw 'To re-throw proper exceptions like Timeout     End If End Try
I am in a situation where when I get an HTTP 400 code from the server, it is a completely legal way of the server telling me what was wrong with my request (using a message in the HTTP response content)  However, the .NET HttpWebRequest raises an exception when the status code is 400.   How do I handle this? For me a 400 is completely legal, and rather helpful. The HTTP content has some important information but the exception throws me off my path.
At the end of every day you will be required to write a review.   At the end of each day you will be required to write a review.   Which one of those sentences is better if this action will repeat itself every day for longer period of time, several weeks for example, maybe even months? Can I use a spell with a casting time of "Bonus Action" as my action? How to use oEmbeds on Post Content during AJAX requests I have an AJAX request that returns a post. The post_content has links to Twitter, YouTube, TED and other platforms that are registered as oEmbed providers in a default, vanilla WordPress install. By now, the WordPress oEmbed handler does not register them and displays plain links and nothing else.   How can I fetch content via AJAX with oEmbed support? Why doesn't Mac OS X source ~/.bashrc? Subsurf Modifier artifacts So I was messing with Subsurf modifier to create a certain sword and then some weird artifacts began to appear (cape-like). I've tried adjusting the Crease, but couldn't achive what I wanted. Basicly, what I whant is the as on the screens, but wo any artifacts :)   Also, here's the .blend file, cause I assume I didn't make myselt 100% clear. Is it possible to dual boot two OS's at the same time? Proof a $(2n-1)$-compact manifold I have no idea how prove that $$\{(z_0,\ldots,z_n)\in\mathbb{C}^{n+1} \quad| \quad z_0^d+z_1^2\ldots+z_n^2=0, \quad |z_0|^2+|z_1|^2\ldots+|z_n|^2=2\}$$ is a $(2n-1)$-compact manifold.  How give the charts. For $n=1$ and $d=2$ not distinguish which 1- manifdold is? What's the best solution to check a users country? Prevent Photos app on OSX from launching when plugging in device The Photos app opens whenever I plug in my phone.    How can this be prevented?  I have seen many solutions for the old iPhoto app that involve changing the "Connecting camera opens" option, but the new app has no such option. Combinations of sets raised to the power of a prime modulus: $\binom{p^{\alpha}-1}k \equiv (-1)^k \pmod p$ What is the easiest way to swap occurrences of two strings in Vim? Get a list of dates between two dates Using standard mysql functions is there a way to write a query that will return a list of days between two dates.  eg given 2009-01-01 and 2009-01-13 it would return a one column table with the values:   2009-01-01   2009-01-02   2009-01-03  2009-01-04   2009-01-05  2009-01-06  2009-01-07  2009-01-08   2009-01-09  2009-01-10  2009-01-11  2009-01-12  2009-01-13   Edit: It appears I have not been clear. I want to GENERATE this list. I have values stored in the database (by datetime) but want them to be aggregated on a left outer join to a list of dates as above (I am expecting null from the right side of some of this join for some days and will handle this). I have some  gained from survey questions.  In my case they are  responses (Strongly Disagree-Disagree-Neutral-Agree-Strongly Agree).  In my data they are coded as 1-5.  I  don't think means would mean much here, so what basic summary statistics are considered usefull? Text in Ubuntu Software Center is unreadable When I do a search in the software center this is what the results look like.    I can only see the text if I select one of them.  I tried changing themes but that didn't fix it. I have append a mesh (rex) from this .blend .  In edit Mode I see different vertices from objcet mode (see pictures). The vertices of belt are missing!  OBJECT MODE:   EDIT MODE:   How can I edit vertices of belt? Is It a bug?  This is my .blend  maybe can help. The iOS-app should provide (at least) the same features as the site and the ability to edit your profile is not so unimportant.  In my opinion, the user should be able to change the every single info-field in his profile (including, but not limited to nickname, description, profile picture) by pressing an "Edit" button which should be located somewhere on his or her profile view. What is the "N+1 selects problem" in ORM (Object-Relational Mapping)? The "N+1 selects problem" is generally stated as a problem in Object-Relational mapping (ORM) discussions, and I understand that it has something to do with having to make a lot of database queries for something that seems simple in the object world.  Does anybody have a more detailed explanation of the problem? How to enable ssh root access on Ubuntu 14.04 I´d like to enable the ssh root access on Ubuntu 14.04. Editing the /etc/ssh_config (PermitRootLogin yes) didn't affect anything. Why don't the Google Docs CTRL + ALT shortcuts work? I'm currently using Google Docs, but when I try to use the keyboard shortcuts like Ctrl+Alt+M it gives µ instead.    Is Chrome (9) overruling Google Docs in some way?  How can I get these shortcuts working?  I'm using Chrome dev 9 on a Dutch Windows 7 with a US-layout keyboard When you edit a message and repost the contents of  its first revision, the repost is eaten up by chat.  Steps to reproduce:   Join any chat room Post something. Let's say you post abcd Edit that to something else. For example, --- Try to post abcd again. The green (pending) message will show up, but when the response is received, it disappears (the server spits out {"id":null,"time":null} as the response)   This happens more often than you think. Many a time I post something, only to realize that I want to use the magic separator (---) to separate it from a previous block. So I up-arrow, Ctrl-X, and type ---, and then I repost the cut text. Which gets eaten up by the server -- making a small change to the repost fixes things.