-
Notifications
You must be signed in to change notification settings - Fork 76
Prettify Error message and stack display, fix #32 . #40
Conversation
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 Report
@@ 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
Continue to review full report at Codecov.
|
…ore call `captureStackTrace` (found in node V6.x). Use strict mode. Prettify tests.
I've already add the tests. I actually don't know whether I should, and how to cover this 0.07... |
lib/MemoryFileSystemError.js
Outdated
if(operation && path) { | ||
this.message += `, ${operation} \'${path}\'`; | ||
} else if(path) { | ||
this.message += `, \'${path}\'`; |
There was a problem hiding this comment.
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.
lib/MemoryFileSystemError.js
Outdated
Error.captureStackTrace(this, this.constructor); | ||
} | ||
} | ||
findOperation() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fine.
Done, review again please. @sokra |
lib/MemoryFileSystem.js
Outdated
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"); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Excuse me, @sokra maybe too busy to notice here? 😄 |
uh, so, the codacy can't pass if not removed it... |
hmmm... weird |
Thanks |
1. Add path and operation name into error message, make it easier to figure out.
before (
error.message
):after:
2. Change first line of stack to use correct message, instance of [object Object].
before (beginning of
error.stack
):after:
It will fix #32 .