Example #1
0
        /// <summary>
        /// Returns a string representation of this exception, including
        /// any inner exceptions.
        /// </summary>
        /// <returns>The string representation of this exception.</returns>
        public override string ToString()
        {
            //
            // This prints the exception Java style. That is, the outermost
            // exception, "Caused by:" to the innermost exception. The
            // stack trace is not nicely indented as with Java, but
            // without string parsing (perhaps tokenize on "\n"), it
            // doesn't appear to be possible to reformat it.
            //
            System.IO.StringWriter sw = new System.IO.StringWriter(CultureInfo.CurrentCulture);
            IceUtilInternal.OutputBase op = new IceUtilInternal.OutputBase(sw);
            op.setUseTab(false);
            op.print(GetType().FullName);
            op.inc();
            IceInternal.ValueWriter.write(this, op);
            sw.Write("\n");
            sw.Write(StackTrace);

            System.Exception curr = InnerException;
            while(curr != null)
            {
                sw.Write("\nCaused by: ");
                sw.Write(curr.GetType().FullName);
                if(!(curr is Ice.Exception))
                {
                    sw.Write(": ");
                    sw.Write(curr.Message);
                }
                sw.Write("\n");
                sw.Write(curr.StackTrace);
                curr = curr.InnerException;
            }

            return sw.ToString();
        }
Example #2
0
        private void warning(Exception ex)
        {
            Debug.Assert(_instance != null);

            using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output       = new IceUtilInternal.OutputBase(sw);
                Ice.ToStringMode           toStringMode = _instance.toStringMode();
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + Ice.Util.identityToString(_current.id, toStringMode));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(_current.facet, "", toStringMode));
                output.print("\noperation: " + _current.operation);
                if (_current.con != null)
                {
                    try
                    {
                        for (Ice.ConnectionInfo p = _current.con.getInfo(); p != null; p = p.underlying)
                        {
                            Ice.IPConnectionInfo ipinfo = p as Ice.IPConnectionInfo;
                            output.print("\nremote host: " + ipinfo.remoteAddress + " remote port: " + ipinfo.remotePort);
                        }
                    }
                    catch (Ice.LocalException)
                    {
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                _instance.initializationData().logger.warning(sw.ToString());
            }
        }
Example #3
0
        protected internal void warning__(System.Exception ex)
        {
            Debug.Assert(instance_ != null);

            using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output = new IceUtilInternal.OutputBase(sw);
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + instance_.identityToString(current_.id));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(current_.facet, ""));
                output.print("\noperation: " + current_.operation);
                if (current_.con != null)
                {
                    Ice.ConnectionInfo connInfo = current_.con.getInfo();
                    if (connInfo is Ice.IPConnectionInfo)
                    {
                        Ice.IPConnectionInfo ipConnInfo = (Ice.IPConnectionInfo)connInfo;
                        output.print("\nremote host: " + ipConnInfo.remoteAddress + " remote port: " +
                                     ipConnInfo.remotePort.ToString());
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                instance_.initializationData().logger.warning(sw.ToString());
            }
        }
Example #4
0
        private void warning(Exception ex)
        {
            Debug.Assert(_communicator != null);
            Debug.Assert(_current != null);

            using (StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output = new IceUtilInternal.OutputBase(sw);
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + _current.Id.ToString(_communicator.ToStringMode));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(_current.Facet, "", _communicator.ToStringMode));
                output.print("\noperation: " + _current.Operation);
                if (_current.Connection != null)
                {
                    try
                    {
                        for (Ice.ConnectionInfo?p = _current.Connection.getInfo(); p != null; p = p.underlying)
                        {
                            if (p is Ice.IPConnectionInfo)
                            {
                                Ice.IPConnectionInfo ipinfo = (Ice.IPConnectionInfo)p;
                                output.print($"\nremote host: {ipinfo.remoteAddress} remote port: {ipinfo.remotePort}");
                                break;
                            }
                        }
                    }
                    catch (Ice.LocalException)
                    {
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                _communicator.Logger.warning(sw.ToString());
            }
        }
Example #5
0
        protected internal void warning__(System.Exception ex)
        {
            Debug.Assert(instance_ != null);

            using(StringWriter sw = new StringWriter(CultureInfo.CurrentCulture))
            {
                IceUtilInternal.OutputBase output = new IceUtilInternal.OutputBase(sw);
                output.setUseTab(false);
                output.print("dispatch exception:");
                output.print("\nidentity: " + instance_.identityToString(current_.id));
                output.print("\nfacet: " + IceUtilInternal.StringUtil.escapeString(current_.facet, ""));
                output.print("\noperation: " + current_.operation);
                if(current_.con != null)
                {
                    for(Ice.ConnectionInfo p = current_.con.getInfo(); p != null; p = p.underlying)
                    {
                        Ice.IPConnectionInfo ipinfo = p as Ice.IPConnectionInfo;
                        output.print("\nremote host: " + ipinfo.remoteAddress + " remote port: " + ipinfo.remotePort);
                    }
                }
                output.print("\n");
                output.print(ex.ToString());
                instance_.initializationData().logger.warning(sw.ToString());
            }
        }