All files CSVError.ts

94.12% Statements 16/17
75% Branches 3/4
83.33% Functions 5/6
93.75% Lines 15/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 291x 1x 1x 2x   1x 5x   1x 1x     8x 8x 8x   8x 8x   1x               1x  
var util = require("util");
export default class CSVError extends Error {
  static column_mismatched(index: number, extra?: string) {
    return new CSVError("column_mismatched", index, extra);
  }
  static unclosed_quote(index: number, extra?: string) {
    return new CSVError("unclosed_quote", index, extra);
  }
  static fromJSON(obj) {
    return new CSVError(obj.err, obj.line, obj.extra);
  }
  constructor(
    public err: string,
    public line: number,
    public extra?: string
  ) {
    super("Error: " + err + ". JSON Line number: " + line + (extra ? " near: " + extra : ""));
    this.name = "CSV Parse Error";
  }
  toJSON() {
    return {
      err: this.err,
      line: this.line,
      extra: this.extra
    }
  }
 
}