errors.js 483 B

12345678910111213141516171819202122
  1. module.exports = class OSError extends Error {
  2. constructor (msg, code, fn = OSError) {
  3. super(`${code}: ${msg}`)
  4. this.code = code
  5. if (Error.captureStackTrace) {
  6. Error.captureStackTrace(this, fn)
  7. }
  8. }
  9. get name () {
  10. return 'OSError'
  11. }
  12. static UNKNOWN_SIGNAL (msg) {
  13. return new OSError(msg, 'UNKNOWN_SIGNAL', OSError.UNKNOWN_SIGNAL)
  14. }
  15. static TITLE_OVERFLOW (msg) {
  16. return new OSError(msg, 'TITLE_OVERFLOW', OSError.TITLE_OVERFLOW)
  17. }
  18. }