errfmt

    1.0.1 • Public • Published

    errfmt

    Call your errors beautiful again 😎 Package to apply makeup over your errors 💄

    Output

    without errfmt

    result

    with errfmt

    colored

    color result

    without color

    without color result

    Usage:

    display whole error

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt({
      colored:true //false by default
    });
    
    //print formatted error
    errfmt.print(err);
    //get formatted error string(no print)
    let fmterr=errfmt.render(err);
    console.log(fmterr);

    or

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt();
    
    //change config on the go
    errfmt.withColor().print(err);
    let fmterr=errfmt.withoutColor().render(err);
    console.log(fmterr);

    display selective error fields

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt({
      colored:true,
      include:["stack","code","message"] //list of error properties to be displayed
    });
    
    errfmt.print(err);

    or

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt({
      colored:true
    });
    
    errfmt.include("code","message","stack").print(err);

    exclude selective error fields

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt({
      colored:true,
      exclude:["stack","code","message"] //list of error properties not to be displayed
    });
    
    errfmt.print(err);

    or

    const Errfmt=require('errfmt');
    const errfmt=new Errfmt({
      colored:true
    });
    
    errfmt.exclude("code","message","stack").print(err);

    Doesn't look good?

    It's not great but you can make it better. Feel free to contribute :)

    Install

    npm i errfmt

    DownloadsWeekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.31 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar