コード例 #1
0
ファイル: DatabaseTask.cs プロジェクト: ravendb/silverlight
        private void ReportError(Exception exception)
        {
            var aggregate = exception as AggregateException;

            if (aggregate != null)
            {
                exception = aggregate.ExtractSingleInnerException();
            }

            innderException = exception;

            var objects      = new List <object>();
            var webException = exception as WebException;

            if (webException != null)
            {
                var httpWebResponse = webException.Response as HttpWebResponse;
                if (httpWebResponse != null)
                {
                    var stream = httpWebResponse.GetResponseStream();
                    if (stream != null)
                    {
                        try
                        {
                            objects = ApplicationModel.ExtractError(stream, httpWebResponse);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }

            if (objects.Count == 0)
            {
                Report(exception.Message, OutputType.Error);
            }
            else
            {
                innderException = new Exception(string.Join(Environment.NewLine, objects));
                foreach (var msg in objects)
                {
                    string value = msg.ToString();
                    if (!string.IsNullOrWhiteSpace(value))
                    {
                        Report(value, OutputType.Error);
                    }
                }
            }
        }