id2msg

Return an error message corresponding to a provided two-character error identifier.

Usage

var id2msg = require( '@stdlib/error/tools/id2msg' );

id2msg( id )

Returns an error message corresponding to a provided two-character error identifier.

var v = id2msg( '8t' );
// e.g., returns 'invalid option. `%s` option must be an array. Option: `%s`.'

If provided an unrecognized error identifier, the function returns null.

var v = id2msg( 'beep_boop' );
// returns null

Examples

var id2msg = require( '@stdlib/error/tools/id2msg' );

var list;
var v;
var i;

list = [
    '01',
    '03',
    '8t',
    '0a',
    '9W'
];

for ( i = 0; i < list.length; i++ ) {
    v = list[ i ];
    console.log( 'id: "%s". msg: "%s".', v, id2msg( v ) );
}

CLI

Usage

Usage: stdlib-id2msg [options] <id>

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.

Examples

$ stdlib-id2msg '8t'
<string>
Did you find this page helpful?