Possible exception(s) thrown by CloudBlockBlob.UploadFromFile(...) - azure-blob-storage

Which exception(s) can be raised by
Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.UploadFromFile(...)?
The C# metadata and online documentation page lists no exceptions for this method. Several examples on StackOverflow and elsewhere catch the base Exception class. Presumably only specific exceptions can be thrown. Quick-Starts and Tutorials on learn.microsoft.com don't include error handling.
Could it be just Microsoft.Azure.Storage.StorageException?

The method can throw lots of exceptions like ArgumentException, NotSupportedException, or etc. However, if your inputs are correct, the most possible exceptions are StorageException for communications against Azure Storage service and IOException for reading the file from local disk.

Related

How to disable warning for specific exceptions?

I do get a warning whenever I throw an exception in my code without explicitly stating it in the docblocs:
I know this can be fixed by adding #throw tags, but the warning is actually not 100% true, as I do handle the exception in /app/Exceptions/Handler.php. I would like to disable the warning for this single exception. Is this possible in PHPStan? I have not found anything in the docs, but in this blog post https://phpstan.org/blog/bring-your-exceptions-under-control it seems that one can have unchecked & checked exceptions, and I believe unchecked exceptions do not need to be declared. However, marking my exception unchecked in phpstan.neon does not get rid of the error:
exceptions:
uncheckedExceptionClasses:
- 'app\Exceptions\AuthenticationException'
I also noticed that the Symfony\Component\HttpKernel\Exception\NotFoundHttpException exception does not trigger the warning. I am not sure why, but it seems there is already a set of exceptions where no #throw is needed.
How can I suppress the warning for my exception?
As Bob has correctly stated this comes from PhpStorm itself and not PHPStan.
You can add any exception to the Unchecked Exception list so it will be ignored by PhpStorm at Settings/Preferences | PHP | Analysis
https://www.jetbrains.com/help/phpstorm/php-missing-throws-tag-s.html
As to why Symfony\Component\HttpKernel\Exception\NotFoundHttpException is not reported -- they have different parents:
NotFoundHttpException extends HttpException extends \RuntimeException (which is in unchecked list)
AuthenticationException extends \Exception
First of all, this is a PhpStorm hint, not a PHPStan.
The point of #throw in docblock is to show you what exceptions your method can throw. If another developer or yourself reuses that method elsewhere, PhpStorm will immediately remind you of that exception and suggest you either wrap it in try-catch or move it to docblock for higher-level processing.
So I see no problem pointing this exception at #throw.

How to tell when Ruby's OpenURI open() function gives a 404 page not found error?

I want to grab the contents of a webpage like this:
open("http://www.ruby-lang.org/")
However, sometimes, that page doesn't exist:
open("http://www.ruby-lang.org/blabla.html")
The open command throws an exception. I know I can catch that exception, but it seems inappropriate in my case. I know there will regularly be bad URLs because visitors and users type in URLs to retrieve.
I don't like the idea of using exceptions for this regular situation. Is there a way that I can know the page was not found without an exception being thrown?
You're using a simplified method to read a file (open-uri), so you're getting a simplified result for errors. It's just not a robust way of doing things beyond simple success/fail.
Check out using Net::HTTP (specifically the request method) or Mechanize or many other available APIs for such tasks.

ASP.NET MVC3: System.NotSupportedException: Specified method is not supported

Hello I am Developing a ASP.NET MVC3 application and MYSQL Database accessed by entity framework. I am done with the deployment part and now i am trying to deploy it on GO DADDY server after deploying it so far every page is working fine but only in one page the following error is coming
Specified method is not supported.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Specified method is not supported.
i have tried a lot searching to find the solution of the error please help me with this
following is the snap shot of the error
You happen to have a query that results in the DbApplyExpression node in the command tree. This node is typically translated to CROSS/OUTER APPLY construct in SQL however MySQL does not support CROSS/OUTER APPLY. Most likely you will have to change your query a little bit to avoid the CROSS/OUTER APPLY. Take a look a this msdn article for more details. I also found something at DevArt website that can be helpful

How to watch for UNHANDLED exceptions only using WaitForDebugEvent family functions?

I'm trying to catch unhandled exceptions in the application and restart it on them using WaitForDebugEvent function. But I can't tell when exception is handled by application (try..catch for example) and when is not. How do I do that? There seem to be no such data in DEBUG_EVENT structure.
If your not catching certain exceptions using WaitForDebugEvent, you might want to try injecting an UnhandledExceptionFilter as well. other than that, check that your processing matches Microsofts Example
In the EXCEPTION_DEBUG_INFO structure, which is in the DEBUG_EVENT structure, there is a field dwFirstChance:
If the dwFirstChance member is nonzero, this is the first time the debugger has encountered the exception. Debuggers typically handle breakpoint and single-step exceptions when they are first encountered. If this member is zero, the debugger has previously encountered the exception. This occurs only if, during the search for structured exception handlers, either no handler was found or the exception was continued.
So you will want to look for times where dwFirstChance is 0.
But if you just want to restart your app when it fails, it might be easier to create another app to watch for the failure of the first one, rather than using the Windows debugging api.

DirectWebRemoting errors

I am supporting an application that has some DWR components. Whenever there is a server error i get a javascript alert that simply says 'error'.
Does anyone know where this might be configured and if there is a way to disable this. Id rather it silently fail at whatever then do this very distracting message.
Use DWR exception handlers in the positions wherever there is a chance for run time errors.
Use try catch mechanism and printstacktrace() in catch block. It works for me!

Resources