Beispiel #1
0
 public void GetErrorList(List <ONExceptionInfo> errorList)
 {
     errorList.Add(new ONExceptionInfo(mCode, mMessage, KeyList));
     if (InnerException != null)
     {
         ONException lONExp = InnerException as ONException;
         if (lONExp != null)
         {
             lONExp.GetErrorList(errorList);
         }
         else
         {
             errorList.Add(new ONExceptionInfo(Code, InnerException.ToString(), null));
         }
     }
 }
Beispiel #2
0
 public bool IsExternal()
 {
     if (InnerException != null)
     {
         ONException lONExp = InnerException as ONException;
         if (lONExp != null)
         {
             return(lONExp.IsExternal());
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Creates the XML message with the error ocurred during the proccess of the request
        /// </summary>
        /// <param name="xmlReader">Variable with the message XML to be treated</param>
        /// <param name="e">Exception to be treated</param>
        /// <param name="dtdVersion">Version of the DTD that follows the XML message</param>
        public static void CreateXMLError(XmlTextWriter xmlWriter, ONException e, double dtdVersion)
        {
            xmlWriter.WriteStartElement("Error");
            xmlWriter.WriteAttributeString("Type", "Model");
            xmlWriter.WriteAttributeString("Number", e.Code.ToString());
            if (dtdVersion <= 2.0) // Normal error.
                xmlWriter.WriteString(e.Message);
            else // Create the trace error.
            {
                xmlWriter.WriteStartElement("Error.Message");
                xmlWriter.WriteString(e.Message);
                xmlWriter.WriteEndElement(); // Error.Message
                xmlWriter.WriteStartElement("Error.Params");

                //The first error.
                if (e.Params.Count > 0)
                {
                    foreach(DictionaryEntry lElement in e.Params)
                    {
                        xmlWriter.WriteStartElement("Error.Param");
                        string lKey = lElement.Key.ToString();
                        bool lIsLiteral = false;
                        if (lKey.StartsWith("*"))
                        {
                            lKey = lKey.Remove(0,1);
                            lIsLiteral = true;
                        }
                        xmlWriter.WriteAttributeString("Key", lKey);
                        if (lIsLiteral)
                            xmlWriter.WriteAttributeString("Type", "Literal");
                        else
                            xmlWriter.WriteAttributeString("Type", "Key");
                        if (lElement.Value != null)
                            xmlWriter.WriteString(lElement.Value.ToString());
                        else
                            xmlWriter.WriteString("");
                        xmlWriter.WriteEndElement(); // Error.Param
                    }
                }

                xmlWriter.WriteEndElement(); // Error.Params

                //Next errors (father errors)
                Exception lException = e;
                xmlWriter.WriteStartElement("Error.Trace");
                while (lException != null)
                {
                    xmlWriter.WriteStartElement("Error.TraceItem");
                    ONException lOnException = lException as ONException;
                    if (lOnException != null) //Model errors.
                    {
                        xmlWriter.WriteAttributeString("Type", "Model");
                        xmlWriter.WriteAttributeString("Number", lOnException.OwnCode.ToString());
                        xmlWriter.WriteStartElement("Error.Message");
                        xmlWriter.WriteString(lOnException.OwnMessage);
                        xmlWriter.WriteEndElement(); // End Error.Message
                        xmlWriter.WriteStartElement("Error.Params");

                        if (lOnException.KeyList.Count > 0)
                        {
                            foreach(DictionaryEntry lElement in lOnException.KeyList)
                            {
                                xmlWriter.WriteStartElement("Error.Param");
                                string lKey = lElement.Key.ToString();
                                bool lIsLiteral = false;
                                if (lKey.StartsWith("*"))
                                {
                                    lKey = lKey.Remove(0,1);
                                    lIsLiteral = true;
                                }
                                xmlWriter.WriteAttributeString("Key", lKey);
                                if (lIsLiteral)
                                    xmlWriter.WriteAttributeString("Type", "Literal");
                                else
                                    xmlWriter.WriteAttributeString("Type", "Key");
                                if (lElement.Value != null)
                                    xmlWriter.WriteString(lElement.Value.ToString());
                                else
                                    xmlWriter.WriteString("");
                                xmlWriter.WriteEndElement(); // Error.Param
                            }
                        }

                        xmlWriter.WriteEndElement(); // Error.Params
                    }
                    else //System errors
                    {
                        xmlWriter.WriteAttributeString("Type", "External");
                        ErrorWrapper lErrorWrapper = new ErrorWrapper(lException);
                        xmlWriter.WriteAttributeString("Number", lErrorWrapper.ErrorCode.ToString());
                        xmlWriter.WriteStartElement("Error.Message");
                        xmlWriter.WriteString(lException.Message);
                        xmlWriter.WriteEndElement(); // End Error.Message
                        xmlWriter.WriteElementString("Error.Params", "");
                    }

                    xmlWriter.WriteEndElement(); // End Error.TraceITem
                    lException = lException.InnerException;
                }
                xmlWriter.WriteEndElement(); // End Error.Trace

                if (e is ONChangeDetectionErrorsException)
                {
                    xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEMS);
                    foreach (DictionaryEntry lDifference in (e as ONChangeDetectionErrorsException).stateDifferences)
                    {
                        xmlWriter.WriteStartElement(XMLTAG_CHANGEDITEM);
                        xmlWriter.WriteAttributeString(ONXml.XMLATT_NAME, (lDifference.Key as string));
                        ONChangeTypeToXML(xmlWriter, (lDifference.Value as ONChangeDetectionInfo), dtdVersion);
                        xmlWriter.WriteEndElement(); // ChangedItem
                    }
                    xmlWriter.WriteEndElement(); // ChangedItems
                }
            }
            xmlWriter.WriteEndElement(); // Error
        }