コード例 #1
0
        public static DataphorFault ExceptionToFault(DataphorException exception)
        {
            DataphorFault fault = new DataphorFault();

            fault.ExceptionClassName = exception.GetType().Name;
            fault.Code          = exception.Code;
            fault.Severity      = exception.Severity;
            fault.Message       = exception.Message;
            fault.Details       = exception.Details;
            fault.ServerContext = exception.ServerContext;
            if (exception.InnerException != null)
            {
                fault.InnerFault = ExceptionToFault(exception.InnerException);
            }

                        #if !SILVERLIGHT
            // Under Silverlight, a ConnectionException will come back as a DataphorException
            // The statement is still present in the Details.
            ConnectionException connectionException = exception as ConnectionException;
            if (connectionException != null)
            {
                fault.Statement = connectionException.Statement;
            }
                        #endif

            SyntaxException syntaxException = exception as SyntaxException;
            if (syntaxException != null)
            {
                fault.Locator   = syntaxException.Locator;
                fault.Line      = syntaxException.Line;
                fault.LinePos   = syntaxException.LinePos;
                fault.Token     = syntaxException.Token;
                fault.TokenType = syntaxException.TokenType;
            }

            CompilerException compilerException = exception as CompilerException;
            if (compilerException != null)
            {
                fault.Locator    = compilerException.Locator;
                fault.Line       = compilerException.Line;
                fault.LinePos    = compilerException.LinePos;
                fault.ErrorLevel = compilerException.ErrorLevel;
            }

            RuntimeException runtimeException = exception as RuntimeException;
            if (runtimeException != null)
            {
                fault.Locator = runtimeException.Locator;
                fault.Line    = runtimeException.Line;
                fault.LinePos = runtimeException.LinePos;
                fault.Context = runtimeException.Context;
            }

            return(fault);
        }
コード例 #2
0
        public static DataphorFault ExceptionToFault(Exception exception)
        {
            DataphorException dataphorException = exception as DataphorException;

            if (dataphorException == null)
            {
                dataphorException = new DataphorException(exception);
            }

            return(ExceptionToFault(dataphorException));
        }
コード例 #3
0
ファイル: RemoteServer.cs プロジェクト: laszlo-kiss/Dataphor
        public static Exception EnsureRemotableException(Exception exception)
        {
            if (!IsRemotableException(exception))
            {
                Exception innerException = null;
                if (exception.InnerException != null)
                {
                    innerException = EnsureRemotableException(exception.InnerException);
                }

                exception = new DataphorException(exception, innerException);
            }

            return(exception);
        }
コード例 #4
0
        public static List <DataphorFault> ExceptionsToFaults(IEnumerable <Exception> exceptions)
        {
            var result = new List <DataphorFault>();

            foreach (Exception exception in exceptions)
            {
                DataphorException dataphorException = exception as DataphorException;
                if (dataphorException == null)
                {
                    dataphorException = new DataphorException(exception);
                }
                result.Add(ExceptionToFault(dataphorException));
            }

            return(result);
        }
コード例 #5
0
        public static NativeCLIException WrapException(Exception exception)
        {
            DataphorException dataphorException = exception as DataphorException;

            if (dataphorException != null)
            {
                return(new NativeCLIException(dataphorException.Message, dataphorException.Code, DataphorSeverityToNativeCLISeverity(dataphorException.Severity), dataphorException.GetDetails(), dataphorException.GetServerContext(), WrapException(dataphorException.InnerException)));
            }

            if (exception != null)
            {
                return(new NativeCLIException(exception.Message, WrapException(exception.InnerException)));
            }

            return(null);
        }
コード例 #6
0
        private void InternalAppendError(IErrorSource source, Exception exception, bool warning)
        {
            if (exception != null)
            {
                ListViewItem item = new ListViewItem();

                item.Tag        = new ErrorItem(exception, source);
                item.ImageIndex = (warning ? 0 : 1);
                // if this is a DataphorException add the exception code to the description
                DataphorException localException = exception as DataphorException;
                item.SubItems.Add(String.Format("{0}{1}", localException != null ? String.Format("({0}:{1}) ", localException.Severity.ToString(), localException.Code.ToString()) : "", ExceptionUtility.BriefDescription(exception)));
                item.SubItems.Add(exception.GetType().ToString());
                _errorListView.Items.Insert(0, item);
                if ((source != null) && (_errorSources[source] == null))
                {
                    _errorSources.Add(source, source);
                    source.Disposed += new EventHandler(ErrorSourceDisposed);
                }
            }
        }
コード例 #7
0
ファイル: PlanNode.cs プロジェクト: cybernetics/Dataphor
        public object Execute(Program program)
        {
                        #if WRAPRUNTIMEEXCEPTIONS
            try
            {
                        #endif

            if (IsBreakable)
            {
                program.Yield(this, false);
            }
            else
            {
                program.CheckAborted();
            }

            // TODO: Compile this call, the TableNode is the only node that uses this hook
            InternalBeforeExecute(program);
            if (DeviceSupported)
            {
                return(program.DeviceExecute(_device, this));
            }
            return(InternalExecute(program));

                        #if WRAPRUNTIMEEXCEPTIONS
        }

        catch (Exception exception)
        {
            bool      isNew   = false;
            Exception toThrow = null;

            RuntimeException runtimeException = exception as RuntimeException;
            if (runtimeException != null)
            {
                if (!runtimeException.HasContext())
                {
                    runtimeException.SetLocator(program.GetLocation(this, true));
                    isNew = true;
                }
                toThrow = runtimeException;
            }

            if ((toThrow == null) && (exception is ControlError))
            {
                throw exception;
            }

            if ((toThrow == null) && (exception is NullReferenceException))
            {
                toThrow = new RuntimeException(RuntimeException.Codes.NilEncountered, exception, program.GetLocation(this, true));
                isNew   = true;
            }

            if (toThrow == null)
            {
                DataphorException dataphorException = exception as DataphorException;
                if (dataphorException != null)
                {
                    if ((dataphorException.Severity == ErrorSeverity.User) || (dataphorException.ServerContext != null) || (dataphorException.Code == (int)RuntimeException.Codes.RuntimeError))
                    {
                        toThrow = dataphorException;
                    }
                    else
                    {
                        toThrow = new RuntimeException(RuntimeException.Codes.RuntimeError, dataphorException.Severity, dataphorException, program.GetLocation(this, true), dataphorException.Message);
                        isNew   = true;
                    }
                }
            }

            if ((toThrow == null) && ((exception is FormatException) || (exception is ArgumentException) || (exception is ArithmeticException)))
            {
                toThrow = new DataphorException(ErrorSeverity.User, DataphorException.ApplicationError, exception.Message, exception);
                isNew   = true;
            }

            if (toThrow == null)
            {
                toThrow = new RuntimeException(RuntimeException.Codes.RuntimeError, ErrorSeverity.Application, exception, program.GetLocation(this, true), exception.Message);
                isNew   = true;
            }

            if (isNew)
            {
                program.ReportThrow();
            }

            if (IsBreakable)
            {
                program.Yield(this, true);
            }

            throw toThrow;
        }
                        #endif
        }
コード例 #8
0
ファイル: DAEException.cs プロジェクト: laszlo-kiss/Dataphor
 protected DAEException(ErrorSeverity severity, int code, string message, string details, string serverContext, DataphorException innerException)
     : base(severity, code, message, details, serverContext, innerException)
 {
 }
コード例 #9
0
 public SyntaxException(ErrorSeverity severity, int code, string message, string details, string serverContext, int line, int linePos, TokenType tokenType, string token, DataphorException innerException)
     : base(severity, code, message, details, serverContext, innerException)
 {
     _line      = line;
     _linePos   = linePos;
     _tokenType = tokenType;
     _token     = token;
 }
コード例 #10
0
 public RuntimeException(ErrorSeverity severity, int code, string message, string details, string serverContext, string locator, int line, int linePos, string context, DataphorException innerException)
     : base(severity, code, message, details, serverContext, innerException)
 {
     _locator = locator;
     _line    = line;
     _linePos = linePos;
     _context = context;
 }
コード例 #11
0
 public ConnectionException(ErrorSeverity severity, int code, string message, string details, string serverContext, string statement, DataphorException innerException)
     : base(severity, code, message, details, serverContext, innerException)
 {
     _statement = statement;
 }