Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8029967

Final steps to have Error compliant with V8 Error API

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None

      The list of missing features to have node modules that rely on v8 error API(specified by : http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi) to work properly.

      Points1) 2) 4) and 5) are must have and can't be implemented in avatar-is without Nashorn support.

      1) Error constructor should capture the stack.
      2) Error constructor should call prepareStackTrace.
      3) captureStackTrace should call prepareStackTrace.
      4) captureStackTrace should support option argument (a function to limit stackTrace). e.g.: Error.captureStackTrace(obj, arguments.callee);
      5) Support for Callsite properties. The most properties we can get, we will not have all.
      6) Stack filename shouldn't be an URL, file/xxx ==> /xxx, some modules load file from the filesystem using this information...
      7) Support for Error.stackTraceLimit, optional, didn't find a module using it. But we could.
      8) stack property of an Error shouldn't be replaced when throwing this error
      9) Error properties are not enumerable, Object.keys called on an Error instance returns an empty array.

      Typical rethrow case:
      var backtrace = new Error;
      Error.captureStackTrace(backtrace);
      doit();
      function doit() {
          throw backtrace;//doit function not in the stack!
      }

      Typical stack customisation:
      function getStackofCallSites() {
      var orig = Error.prepareStackTrace;
      Error.prepareStackTrace = function(_, stack){ return stack; };
      var err = {};
      Error.captureStackTrace(err, arguments.callee);
      Error.prepareStackTrace = orig;
      return err.stack;
      }

            sundar Sundararajan Athijegannathan
            jfdenise Jean-Francois Denise (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: