Exemple #1
0
        private string MakeErrorMsg(string what, GrainReference grainReference, Exception exc)
        {
            string errorCode = AzureStorageUtils.ExtractRestErrorCode(exc);

            return(string.Format("Error from storage provider during {0} for grain Type={1} Pk={2} Id={3} Error={4}\n {5}",
                                 what, grainTypeName, grainReference.GrainId.ToDetailedString(), grainReference, errorCode, TraceLogger.PrintException(exc)));
        }
        public void AzureTableErrorCode_ExtractRestErrorCode_BadData_Null()
        {
            string xml = null;

            var exc     = new DataServiceClientException(xml);
            var strCode = AzureStorageUtils.ExtractRestErrorCode(exc);

            Assert.IsNull(strCode);

            var wrapped = new AggregateException(exc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(wrapped);
            Assert.IsNull(strCode);
        }
        public void AzureTableErrorCode_UpdateConditionNotSatisfied()
        {
            string xml =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">" +
                "<code>UpdateConditionNotSatisfied</code>" +
                "<message xml:lang=\"en-US\">The update condition specified in the request was not satisfied." +
                "RequestId:0781ff48-0002-0023-3167-3673bb000000" +
                "Time:2014-10-29T14:43:17.4073101Z</message>" +
                "</error>";

            var clientExc = new DataServiceClientException(xml);
            var strCode   = AzureStorageUtils.ExtractRestErrorCode(clientExc);

            Assert.AreEqual(TableErrorCodeStrings.UpdateConditionNotSatisfied, strCode);
        }
        public void AzureTableErrorCode_ExtractRestErrorCode()
        {
            string xml =
                "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" +
                "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">" +
                "<code>OperationTimedOut</code>" +
                "<message xml:lang=\"en-US\">Operation could not be completed within the specified time. RequestId:6b75e963-c56c-4734-a656-066cfd03f327 Time:2011-10-09T19:33:26.7631923Z</message>" +
                "</error>";
            var exc     = new DataServiceClientException(xml);
            var strCode = AzureStorageUtils.ExtractRestErrorCode(exc);

            Assert.AreEqual(StorageErrorCodeStrings.OperationTimedOut, strCode);

            var wrapped = new AggregateException(exc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(wrapped);
            Assert.AreEqual(StorageErrorCodeStrings.OperationTimedOut, strCode);
        }
        public void AzureTableErrorCode_ExtractRestErrorCode_ResourceNotFound()
        {
            string xml =
                "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" +
                "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">" +
                "<code>ResourceNotFound</code>" +
                "<message xml:lang=\"en-US\">The specified resource does not exist." +
                "RequestId:23e7a3b9-3d08-4461-ba49-737c9c211142" +
                "Time:2013-10-10T17:35:59.7597108Z</message>" +
                "</error>";

            var clientExc = new DataServiceClientException(xml);
            var strCode   = AzureStorageUtils.ExtractRestErrorCode(clientExc);

            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);

            var clientWrapped1 = new AggregateException(clientExc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(clientWrapped1);
            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);

            var clientWrapped2 = new OrleansException("client", clientExc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(clientWrapped2);
            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);

            var clientWrapped3 = new DataServiceQueryException("QueryException", clientExc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(clientWrapped3);
            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);

            var clientWrapped4 = new DataServiceQueryException("Wrapped-clientWrapper1", clientWrapped1);

            strCode = AzureStorageUtils.ExtractRestErrorCode(clientWrapped4);
            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);

            var superWrapped1 = new DataServiceQueryException("SuperWrapped-Client4",
                                                              new AggregateException("Wrapper5", clientWrapped4));

            strCode = AzureStorageUtils.ExtractRestErrorCode(superWrapped1);
            Assert.AreEqual(StorageErrorCodeStrings.ResourceNotFound, strCode);
        }
        public void AzureTableErrorCode_ExtractRestErrorCode_InsufficientAccountPermissions()
        {
            string xml =
                "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" +
                "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">" +
                "<code>InsufficientAccountPermissions</code>" +
                "<message xml:lang=\"en-US\">The account being accessed does not have sufficient permissions to execute this operation." +
                "RequestId:f6f4d0d3-879f-414c-bdf4-582faa7581e8" +
                "Time:2012-05-14T18:13:13.1526007Z</message>" +
                "</error>";
            var exc     = new DataServiceClientException(xml);
            var strCode = AzureStorageUtils.ExtractRestErrorCode(exc);

            Assert.AreEqual("InsufficientAccountPermissions", strCode);

            var wrapped = new AggregateException(exc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(wrapped);
            Assert.AreEqual("InsufficientAccountPermissions", strCode);
        }
        public void AzureTableErrorCode_ExtractRestErrorCode_ServerBusy()
        {
            string xml =
                "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" +
                "<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">" +
                "<code>ServerBusy</code>" +
                "<message xml:lang=\"en-US\">The server is busy." +
                "RequestId:14ab4de6-fe80-4a45-a364-b0c2a27a4a86" +
                "Time:2013-09-24T23:29:13.4913945Z</message>" +
                "</error>";

            var exc     = new DataServiceClientException(xml);
            var strCode = AzureStorageUtils.ExtractRestErrorCode(exc);

            Assert.AreEqual(StorageErrorCodeStrings.ServerBusy, strCode);

            var wrapped = new AggregateException(exc);

            strCode = AzureStorageUtils.ExtractRestErrorCode(wrapped);
            Assert.AreEqual(StorageErrorCodeStrings.ServerBusy, strCode);

            //Assert.IsTrue(Async_AzureTableDataManager<SiloMetricsData>.IsRetriableHttpError((HttpStatusCode)500, "ServerBusy"));
        }