visitEcxceptionBody()

in lib/generator.js [1563:1591]


  visitEcxceptionBody(ast, extendOn, exceptionName, level) {
    assert.equal(ast.type, 'exceptionBody');
    this.visitFieldsInit(ast, level, exceptionName, 'exception', this.extendBaseErr(extendOn));
    let node;
    
    this.emit(`self.name = '${exceptionName}Exception'\n`, level + 2);
    for (let i = 0; i < ast.nodes.length; i++) {
      node = ast.nodes[i];
      let comments = DSL.comment.getFrontComments(this.comments, node.tokenRange[0]);
      this.visitComments(comments, level);
      let param = _avoidKeywords(_snakeCase(_escape(_name(node.fieldName))));
      if(param === 'name') {
        continue;
      }
      this.emit(`self.${param} = ${param}\n`, level + 2);
    }
    this.emit('\n');
    if (node) {
      //find the last node's back comment
      let comments = DSL.comment.getBetweenComments(this.comments, node.tokenRange[0], ast.tokenRange[1]);
      this.visitComments(comments, level);
    }

    if (ast.nodes.length === 0) {
      //empty block's comment
      let comments = DSL.comment.getBetweenComments(this.comments, ast.tokenRange[0], ast.tokenRange[1]);
      this.visitComments(comments, level);
    }
  }