MemoryFileSystemError.js 799 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. class MemoryFileSystemError extends Error {
  3. constructor(err, path, operation) {
  4. super(err, path);
  5. // Set `name` and `message` before call `Error.captureStackTrace` \
  6. // so that we will obtain the correct 1st line of stack, like:
  7. // [Error]: [Message]
  8. this.name = this.constructor.name;
  9. var message = [`${err.code}:`, `${err.description},`];
  10. // Add operation name and path into message, similar to node `fs` style.
  11. if(operation) {
  12. message.push(operation);
  13. }
  14. message.push(`\'${path}\'`);
  15. this.message = message.join(' ');
  16. this.code = err.code;
  17. this.errno = err.errno;
  18. this.path = path;
  19. this.operation = operation;
  20. if(Error.captureStackTrace) {
  21. Error.captureStackTrace(this, this.constructor);
  22. }
  23. }
  24. }
  25. module.exports = MemoryFileSystemError;