# All files / csv2json/src CSVError.ts

88.24% Statements 15/17
75% Branches 3/4
66.67% Functions 4/6
87.5% Lines 14/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
    241x
    1x
    1x
    2x

    1x
    4x

    1x

    6x
    6x
    6x

    6x
    6x

    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 fromArray(arr:any[]){
        return new CSVError(arr[0],arr[1],arr[2]);
      }
      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";
      }
      toString(){
        return JSON.stringify([this.err, this.line, this.extra]);
      }
    }