public static void CheckResult(IntPtr scriptHandle, bool terminated, bool disposeScriptOnException)
 {
     if (terminated)
         throw new Js1Exception(
             -2, "Failed to compile script. Script execution terminated.  Timeout expired. (1)");
     if (scriptHandle == IntPtr.Zero)
         throw new Js1Exception(
             -1, "Failed to compile script. Script execution terminated.  Timeout expired. (2)");
     int? errorCode = null;
     string errorMessage = null;
     _reportErrorCallback =
         // NOTE: this local delegate must go to a field to keep references while ReportErrors is being executed
         (code, message) =>
             {
                 //NOTE: do not throw exceptions directly in this handler
                 // let the CPP code clean up 
                 errorCode = code;
                 errorMessage = message;
             };
     Js1.ReportErrors(scriptHandle, _reportErrorCallback);
     if (errorCode != null)
     {
         if (disposeScriptOnException)
         {
             Js1.DisposeScript(scriptHandle);
         }
         if (errorCode == 2)
             throw new Js1Exception(
                 errorCode.Value, "Failed to compile script. Script execution terminated.  Timeout expired. (3)");
         throw new Js1Exception(errorCode.Value, errorMessage);
     }
 }
Example #2
0
        public static void CheckResult(IntPtr scriptHandle, bool terminated, bool disposeScriptOnException)
        {
            if (terminated)
            {
                throw new Js1Exception(
                          -2, "Failed to compile script. Script execution terminated.  Timeout expired. (1)");
            }
            if (scriptHandle == IntPtr.Zero)
            {
                throw new Js1Exception(
                          -1, "Failed to compile script. Script execution terminated.  Timeout expired. (2)");
            }
            int?   errorCode    = null;
            string errorMessage = null;

            _reportErrorCallback =
                // NOTE: this local delegate must go to a field to keep references while ReportErrors is being executed
                (code, message) => {
                //NOTE: do not throw exceptions directly in this handler
                // let the CPP code clean up
                errorCode    = code;
                errorMessage = message;
            };
            Js1.ReportErrors(scriptHandle, _reportErrorCallback);
            if (errorCode != null)
            {
                if (disposeScriptOnException)
                {
                    Js1.DisposeScript(scriptHandle);
                }

                if (errorCode == 2)
                {
                    throw new Js1Exception(
                              errorCode.Value,
                              "Failed to compile script. Script execution terminated.  Timeout expired. (3)");
                }
                throw new Js1Exception(errorCode.Value, errorMessage);
            }
        }
Example #3
0
 public static void CheckResult(IntPtr scriptHandle, bool disposeScriptOnException)
 {
     int? errorCode = null;
     string errorMessage = null;
     _reportErrorCallback =
         // NOTE: this local delegate must go to a field to keep references while ReportErrors is being executed
         (code, message) =>
             {
                 //NOTE: do not throw exceptions directly in this handler
                 // let the CPP code clean up
                 errorCode = code;
                 errorMessage = message;
             };
     Js1.ReportErrors(scriptHandle, _reportErrorCallback);
     if (errorCode != null)
     {
         if (disposeScriptOnException)
         {
             Js1.DisposeScript(scriptHandle);
         }
         throw new Js1Exception(errorCode.Value, errorMessage);
     }
 }
Example #4
0
        public static void CheckResult(IntPtr scriptHandle, bool disposeScriptOnException)
        {
            int?   errorCode    = null;
            string errorMessage = null;

            _reportErrorCallback =
                // NOTE: this local delegate must go to a field to keep references while ReportErrors is being executed
                (code, message) =>
            {
                //NOTE: do not throw exceptions directly in this handler
                // let the CPP code clean up
                errorCode    = code;
                errorMessage = message;
            };
            Js1.ReportErrors(scriptHandle, _reportErrorCallback);
            if (errorCode != null)
            {
                if (disposeScriptOnException)
                {
                    Js1.DisposeScript(scriptHandle);
                }
                throw new Js1Exception(errorCode.Value, errorMessage);
            }
        }