locked
Error Handling for Windows Azure Storage Migration from 1.7 to 2.0 RRS feed

  • Question

  • I change the following code from:

    try
    {
        blob.FetchAttributes();
    }
    catch (StorageClientException e)
    {
        if (e.ErrorCode == StorageErrorCode.ResourceNotFound)
            ....
    }
    

    to:

    try
    {
        blob.FetchAttributes();
    }
    catch (StorageException e)
    {
        if (e.RequestInformation.ExtendedErrorInformation.ErrorCode == StorageErrorCodeStrings.ResourceNotFound)
            ....
    }
    

    After i run it, it gives me a NullException because:

    e.RequestInformation.ExtendedErrorInformation = NULL,

    but

    e.RequestInformation.HTTPStatusMessage = "The specified blob does not exist."

    and

    e.RequestInformation.HTTPStatusCode = 404

    I was thinking to test for the HttpStatusMessage, but i feel it is not that safe to do it since the message could change over time, Can anyone help me what should I do in this case if i want to keep my original logic behavior?

    Monday, March 25, 2013 7:44 PM

Answers

All replies

  • I think you must first check the blob, because error code 404 states "Not found". Which means blob isn't present in your case whose attributes you are fetching.

    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Tuesday, March 26, 2013 7:05 AM
  • Thank you so much for your reply, you are correct, the blob doesn't exist, now i just want to detect this error and handle it, do you have any suggestion on that? thanks in advance
    Wednesday, March 27, 2013 2:25 PM
  • Weiqiang Zhang,

             if you found it ans answered, you can mark the post as an answer, will help all the forum visitors in future, incase they came across same problem.

    Thanks


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Thursday, March 28, 2013 5:46 AM
  • No, I understand the blob does not exist, my question is how do i do the error handling in this case when the error code is null.
    Thursday, March 28, 2013 7:20 PM
  • HI

    Why don't you check HTTPStatusCode ?

    404 error always means not found.

    Thanks.


    Dino He
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, April 1, 2013 7:52 AM