• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3function createError(msg, code, props) {
4    var err = msg instanceof Error ? msg : new Error(msg);
5    var key;
6
7    if (typeof code === 'object') {
8        props = code;
9    } else if (code != null) {
10        err.code = code;
11    }
12
13    if (props) {
14        for (key in props) {
15            err[key] = props[key];
16        }
17    }
18
19    return err;
20}
21
22module.exports = createError;
23