Package com.github.sommeri.less4j.core.problems

Source Code of com.github.sommeri.less4j.core.problems.BugHappened

package com.github.sommeri.less4j.core.problems;

import com.github.sommeri.less4j.core.ast.ASTCssNode;
import com.github.sommeri.less4j.core.parser.HiddenTokenAwareTree;
import com.github.sommeri.less4j.utils.ProblemsPrinter.AbsoluteSourceNamePrinter;

@SuppressWarnings("serial")
public class BugHappened extends RuntimeException {

  private static final String PREFIX = "Bug, please report issue: ";

  public BugHappened(String message, HiddenTokenAwareTree offendingNode) {
    super(PREFIX + message + errorPlace(offendingNode));
  }

  public BugHappened(String message, ASTCssNode offendingNode) {
    super(PREFIX + message + errorPlace(offendingNode));
  }

  public BugHappened(Throwable th, ASTCssNode object) {
    super(PREFIX + errorPlace(object), th);
  }

  private static String errorPlace(ASTCssNode offendingNode) {
    if (offendingNode==null)
      return "";

    AbsoluteSourceNamePrinter printer = new AbsoluteSourceNamePrinter();
    String filename = printer.printSourceName(offendingNode.getSource());
   
    return "\n Offending place: " + filename + " " + offendingNode.getSourceLine() + ":" + offendingNode.getSourceColumn();
  }
 
  private static String errorPlace(HiddenTokenAwareTree offendingNode) {
    if (offendingNode==null)
      return "";

    AbsoluteSourceNamePrinter printer = new AbsoluteSourceNamePrinter();
    String filename = printer.printSourceName(offendingNode.getSource());
   
    return "\n Offending place: " + filename + " " + offendingNode.getLine() + ":" + (offendingNode.getCharPositionInLine() + 1);
  }
 
}
TOP

Related Classes of com.github.sommeri.less4j.core.problems.BugHappened

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.