0

내 기능을 acctualy 일부 envolved 예외를 관리합니다.자바 스크립트에 예외 스택 트레이스를 인쇄하려면 어떻게해야합니까?

throw { 
     name:"RangeWithValues", 
     message:"The result range cells must be empty", 
     //stack:e, 
     toString:function(){return (this.name + ": " + this.message);} 
    }; 

이되지 않습니다 : :

throw { 
      name:"RangeWithValues", 
      message:"The result range cells must be empty", 
      //stack:e, 
      toString:function(){return (this.name + ": " + this.message + (this.hasOwnProperty(stack)?("\nCaused by: "+stack):""));} 
     }; 

그것을

내 질문이 작동 간단하다 ... 레이어 1 층 (2)에 예외를 재 - 발생하지만 그것은 중요하지 않습니다 google preadsheet에 [object Object]를 인쇄합니다. 스택 추적을 인쇄하고 싶습니다. 나는 내가 당신을 제공하기 위해 더 많은 정보가 필요하면 잘 모릅니다 , 내 질문의 verry 간단한 =의 S

답변

0

직접 개체 사용자 지정 오류를 생성하는 대신 던질 것 같다 :

function CustomError(name, message) { 
    this.name = (name || ''); 
    this.stack = (new Error()).stack; 
    this.message = (message || '') + ' ' + this.stack; 
} 

CustomError.prototype = Error.prototype; 

throw new CustomError('RangeWithValues', 'The result range cells must be empty'); 

는 또한 stacktrace.js 참조, 프레임 워크 모든 웹 브라우저에서 스택 추적을 얻기위한 마이크로 라이브러리.