Beispiel #1
0
        private JsRuntimeException ConvertJavaScriptExceptionToJsRuntimeException(
            OriginalJsException jsException)
        {
            string          category   = string.Empty;
            OriginalJsValue errorValue = jsException.Error;

            if (errorValue.IsObject())
            {
                OriginalObjectInstance errorObject           = errorValue.AsObject();
                OriginalJsValue        categoryPropertyValue = errorObject.Get("name");

                if (categoryPropertyValue.IsString())
                {
                    category = categoryPropertyValue.AsString();
                }
            }

            var jsRuntimeException = new JsRuntimeException(jsException.Message, ENGINE_NAME, ENGINE_VERSION,
                                                            jsException)
            {
                Category     = category,
                LineNumber   = jsException.LineNumber,
                ColumnNumber = jsException.Column,
                Source       = jsException.Source,
                HelpLink     = jsException.HelpLink
            };

            return(jsRuntimeException);
        }
        private JsRuntimeException ConvertJavaScriptExceptionToJsRuntimeException(
            OriginalJsException jsException)
        {
            string          category     = string.Empty;
            int             lineNumber   = jsException.LineNumber;
            int             columnNumber = jsException.Column + 1;
            string          message      = jsException.Message;
            OriginalJsValue errorValue   = jsException.Error;

            if (errorValue.IsObject())
            {
                OriginalObjectInstance errorObject           = errorValue.AsObject();
                OriginalJsValue        categoryPropertyValue = errorObject.Get("name");

                if (categoryPropertyValue.IsString())
                {
                    category = categoryPropertyValue.AsString();
                }

                message = GenerateErrorMessageWithLocation(category, message,
                                                           jsException.Location.Source, lineNumber, columnNumber);
            }

            var jsRuntimeException = new JsRuntimeException(message, EngineName, EngineVersion,
                                                            jsException)
            {
                Category     = category,
                LineNumber   = lineNumber,
                ColumnNumber = columnNumber
            };

            return(jsRuntimeException);
        }
        private static WrapperException WrapJavaScriptException(
            OriginalJavaScriptException originalJavaScriptException)
        {
            WrapperException wrapperException;
            string           message = originalJavaScriptException.Message;

            if (string.IsNullOrWhiteSpace(message))
            {
                message = "An unknown error occurred";
            }
            string description  = message;
            string type         = string.Empty;
            string documentName = originalJavaScriptException.Location.Source;
            int    lineNumber   = originalJavaScriptException.LineNumber;
            int    columnNumber = originalJavaScriptException.Column + 1;

            OriginalValue errorValue = originalJavaScriptException.Error;

            if (errorValue.IsObject())
            {
                OriginalObjectInstance errorObject = errorValue.AsObject();

                OriginalValue namePropertyValue = errorObject.Get("name");
                if (namePropertyValue.IsString())
                {
                    type = namePropertyValue.AsString();
                }
            }

            if (!string.IsNullOrEmpty(type))
            {
                message = JsErrorHelpers.GenerateScriptErrorMessage(type, description, documentName, lineNumber,
                                                                    columnNumber);

                var wrapperRuntimeException = new WrapperRuntimeException(message, EngineName, EngineVersion,
                                                                          originalJavaScriptException)
                {
                    Type         = type,
                    DocumentName = documentName,
                    LineNumber   = lineNumber,
                    ColumnNumber = columnNumber
                };

                wrapperException = wrapperRuntimeException;
            }
            else
            {
                wrapperException = new WrapperException(message, EngineName, EngineVersion,
                                                        originalJavaScriptException);
            }

            wrapperException.Description = description;

            return(wrapperException);
        }
Beispiel #4
0
            private Client.Exceptions.Documents.Patching.JavaScriptException CreateFullError(JavaScriptException e)
            {
                string msg;

                if (e.Error.IsString())
                {
                    msg = e.Error.AsString();
                }
                else if (e.Error.IsObject())
                {
                    msg = JsBlittableBridge.Translate(_jsonCtx, ScriptEngine, e.Error.AsObject()).ToString();
                }
                else
                {
                    msg = e.Error.ToString();
                }

                msg = "At " + e.Column + ":" + e.LineNumber + " " + msg;
                var javaScriptException = new Client.Exceptions.Documents.Patching.JavaScriptException(msg, e);

                return(javaScriptException);
            }
Beispiel #5
0
            private static Client.Exceptions.Documents.Patching.JavaScriptException CreateFullError(DocumentsOperationContext ctx, JavaScriptException e)
            {
                string msg;

                if (e.Error.IsString())
                {
                    msg = e.Error.AsString();
                }
                else if (e.Error.IsObject())
                {
                    msg = JsBlittableBridge.Translate(ctx, e.Error.AsObject()).ToString();
                }
                else
                {
                    msg = e.Error.ToString();
                }

                msg = "At " + e.Column + ":" + e.LineNumber + Environment.NewLine + msg;
                var javaScriptException = new Client.Exceptions.Documents.Patching.JavaScriptException(msg, e);

                return(javaScriptException);
            }