Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Prettify Error message and stack display, fix #32 . #40

Merged
merged 10 commits into from
Jun 18, 2017

Conversation

mc-zone
Copy link
Member

@mc-zone mc-zone commented May 30, 2017

1. Add path and operation name into error message, make it easier to figure out.

before (error.message):

no such file or directory
illegal operation on a directory
operation not permitted
file already exists
not a directory

after:

ENOENT: no such file or directory, unlinkSync '/test/abcd'
EISDIR: illegal operation on a directory, writeFileSync '/test/dir'
EPERM: operation not permitted, rmdirSync '/'
EEXIST: file already exists, mkdirSync '/test/dir'
ENOTDIR: not a directory, mkdirSync '/test/file'

2. Change first line of stack to use correct message, instance of [object Object].

before (beginning of error.stack):

Error: [object Object]
    at MemoryFileSystem.readFileSync (...

after:

MemoryFileSystemError: ENOENT: no such file or directory, readFileSync '/fail/file'
    at MemoryFileSystem.readFileSync ( ...

It will fix #32 .

mc-zone added 2 commits May 31, 2017 00:28
1. Add path and operation name into error message, make it easier to figure out.

2. Change first line of stack to use correct message, instance of [object
Object].
@codecov
Copy link

codecov bot commented May 30, 2017

Codecov Report

Merging #40 into master will increase coverage by 0.11%.
The diff coverage is 97.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
+ Coverage   96.12%   96.24%   +0.11%     
==========================================
  Files           3        4       +1     
  Lines         284      293       +9     
  Branches       65       67       +2     
==========================================
+ Hits          273      282       +9     
  Misses         11       11
Impacted Files Coverage Δ
lib/join.js 100% <ø> (ø) ⬆️
lib/MemoryFileSystemError.js 100% <100%> (ø)
lib/MemoryFileSystem.js 99.06% <100%> (-0.03%) ⬇️
lib/normalize.js 83.33% <83.33%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b96090...5fcc26c. Read the comment docs.

@mc-zone mc-zone closed this May 31, 2017
@mc-zone mc-zone reopened this May 31, 2017
…ore call `captureStackTrace` (found in node V6.x).

Use strict mode.

Prettify tests.
@mc-zone mc-zone closed this May 31, 2017
@mc-zone mc-zone reopened this May 31, 2017
@jsf-clabot
Copy link

jsf-clabot commented May 31, 2017

CLA assistant check
All committers have signed the CLA.

@mc-zone
Copy link
Member Author

mc-zone commented Jun 1, 2017

Coverage decreased (-0.07%) to 96.403%

I've already add the tests. I actually don't know whether I should, and how to cover this 0.07...
But I think it's satisfying for review now. :p @sokra @SpaceK33z @TheLarkInn

if(operation && path) {
this.message += `, ${operation} \'${path}\'`;
} else if(path) {
this.message += `, \'${path}\'`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not covered. If unused remove it.

Error.captureStackTrace(this, this.constructor);
}
}
findOperation() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do that.

Instead pass the operation name in the error constructor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine.

@mc-zone
Copy link
Member Author

mc-zone commented Jun 1, 2017

Done, review again please. @sokra

current[path[i]] = {"":true};
return;
}

_remove(_path, name, testFn) {
const path = pathToArray(_path);
if(path.length === 0) {
throw new MemoryFileSystemError(errors.code.EPERM, _path);
throw new MemoryFileSystemError(errors.code.EPERM, _path, "remove");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove is not an operation: pass rmdir or unlink

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. my bad.

.eslintrc.json Outdated
@@ -202,7 +202,6 @@
"error",
"always"
],
"strict": "error",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this doesn't have to be removed. You have a "use strict" in the file?

Copy link
Member Author

@mc-zone mc-zone Jun 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, I extracted MemoryFileSystemError to a standalone file. So add "use strict" for it's classes declaration, otherwise it will broken in node v4.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sokra Does this have any side effects?

@mc-zone
Copy link
Member Author

mc-zone commented Jun 7, 2017

Excuse me, @sokra maybe too busy to notice here? 😄
Must I remove the "use strict"? Could you give any reason? Please.

@mc-zone
Copy link
Member Author

mc-zone commented Jun 14, 2017

uh, so, the codacy can't pass if not removed it...

@sokra
Copy link
Member

sokra commented Jun 14, 2017

hmmm... weird

@sokra
Copy link
Member

sokra commented Jun 18, 2017

Thanks

@sokra sokra merged commit 67cec91 into webpack:master Jun 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"no such file or directory" Doesn't Show Errant File/Directory Path
4 participants