-
Notifications
You must be signed in to change notification settings - Fork 18
ArchivistModuleError, module refactoring #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
f87ea05 to
884c043
Compare
|
istanbul needed to be upgraded to alpha so that fat arrow functions would be correctly processed. |
884c043 to
1e390a0
Compare
| }, details) | ||
| }); | ||
|
|
||
| this.type = ArchivistModuleError; |
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.
What's the purpose of this? error.constructor === error.type
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.
Ah, I think that should be a string. Ill fix it
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.
Then I would suggest having MageError automatically assign this.type = this.constructor.name;, so you never have to type that line of code again.
| value.applyDiff(diff); | ||
| } catch (e) { | ||
| return state.error(null, e, cb); | ||
| throw new ArchivistModuleError('Actor not allowed to set diff on this topic', state, topic, index); |
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.
Wouldn't you want to know who did this, or is that pulled off the state object or something?
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.
The state contains the actorId and that actorId will be logged.
Refactored the code to use promises, reduce copy/pastes, and throw ArchivistModuleError which contain more details for logging purposes.
1e390a0 to
266537b
Compare
|
Everything should be fixed. |
| } | ||
|
|
||
| return topicApi; | ||
| }; |
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.
For getTopicApi and getClientVault.. why not just have the existing functions throw? I can imagine you're trying to stay BC, but it seems a bit overkill and inconsistent to have these in 2 places.
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.
The goal was to make the errors being logged more consistent (e.g. if you hit archivist client API you always get more or less the same kind of errors). So it's a bit redundant, but it does currently serve a purpose.
| exports.acl = ['*']; | ||
|
|
||
| var options = { | ||
| exports.execute = async function (state, topic, index, data, mediaType, encoding, expirationTime) { |
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.
Will async not break on Node 6?
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.
Yes, it would. It takes 7 with a flags and 7.6 and up without flag.
I'll fix that.
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.
Going back to Promises-based doesn't really help us in terms of readability here. I'd rather wait for this to get merged once we remove support for Node <8.
Refactored the code to use promises, reduce copy/pastes, and
throw ArchivistModuleError which contain more details for
logging purposes.