* Map an Error's .name property into the actual event name that is emitted * by the restify server object. * * @function * @private errEvtNameFromError * @param {Object} err - an error object * @returns {String} an event name to emit
(err)
| 1732 | * @returns {String} an event name to emit |
| 1733 | */ |
| 1734 | function errEvtNameFromError(err) { |
| 1735 | if (err.name === 'ResourceNotFoundError') { |
| 1736 | // remap the name for router errors |
| 1737 | return 'NotFound'; |
| 1738 | } else if (err.name === 'InvalidVersionError') { |
| 1739 | // remap the name for router errors |
| 1740 | return 'VersionNotAllowed'; |
| 1741 | } else if (err.name) { |
| 1742 | return err.name.replace(/Error$/, ''); |
| 1743 | } |
| 1744 | // If the err is not an Error, then just return an empty string |
| 1745 | return ''; |
| 1746 | } |
| 1747 | |
| 1748 | /** |
| 1749 | * Mounts a chain on the given path against this HTTP verb |