Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@stelcheck
Copy link
Member

Refactored the code to use promises, reduce copy/pastes, and
throw ArchivistModuleError which contain more details for
logging purposes.

@stelcheck stelcheck added this to the 1.5.0 milestone Dec 11, 2017
@stelcheck stelcheck requested a review from a team December 11, 2017 08:32
@stelcheck stelcheck force-pushed the features/better-archivist-logging branch from f87ea05 to 884c043 Compare December 12, 2017 03:28
@stelcheck
Copy link
Member Author

stelcheck commented Dec 12, 2017

istanbul needed to be upgraded to alpha so that fat arrow functions would be correctly processed.

@stelcheck stelcheck modified the milestones: 1.5.0, 2.0 Dec 19, 2017
@stelcheck stelcheck force-pushed the features/better-archivist-logging branch from 884c043 to 1e390a0 Compare January 22, 2018 04:51
}, details)
});

this.type = ArchivistModuleError;
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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);
Copy link
Member

@ronkorving ronkorving Jan 22, 2018

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?

Copy link
Member Author

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.
@stelcheck stelcheck force-pushed the features/better-archivist-logging branch from 1e390a0 to 266537b Compare February 8, 2018 10:33
@stelcheck
Copy link
Member Author

Everything should be fixed.

}

return topicApi;
};
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants