Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Improve Error Categorization and Formatting #86

Merged
merged 7 commits into from
Feb 12, 2018
Merged

Improve Error Categorization and Formatting #86

merged 7 commits into from
Feb 12, 2018

Conversation

linuxwolf
Copy link
Contributor

@linuxwolf linuxwolf commented Feb 9, 2018

Fixes #64

@ghost ghost assigned linuxwolf Feb 9, 2018
@ghost ghost added the in progress We are actively working on it. label Feb 9, 2018
@linuxwolf linuxwolf added this to the 0.1.7 milestone Feb 9, 2018
@linuxwolf linuxwolf changed the title 64 errors Improve Error Categorization and Formatting Feb 9, 2018
@linuxwolf linuxwolf requested a review from a team February 12, 2018 18:08
@linuxwolf
Copy link
Contributor Author

@sashei @mozilla-lockbox/product-integrity

This should be ready to look at. There is one change from the spec in #64, which is that if no separate message is included, then only the reason is used for the error message:

  • error with no special message: LOCKED
  • error with extra message: LOCKED: must be unlocked in order to rebase

I don't think there's any practical way to PI verify short of analyzing the updated unit-tests.

Copy link

@kimberlythegeek kimberlythegeek left a comment

Choose a reason for hiding this comment

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

Just a couple of nitpicks, but overall looks good.

assert.strictEqual(err.reason, DataStoreError.INVALID_ITEM);
assert.deepEqual(err.details, {
"entry.username": "string.max"
});
}
});
it("fails to prepare an item with excessive entry.psssword", () => {
it("fails to prepare an item with excessive entry.passsword", () => {

Choose a reason for hiding this comment

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

I'm guessing this is meant to be entry.password?

* @member {string} DataStoreError.CRYPTO
*/
/**
* An operation requires network connectivety, but there is none.

Choose a reason for hiding this comment

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

connectivity*

reason = message;
message = "";
constructor(reason, message) {
if (-1 === REASONS.indexOf(reason)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if we want to use Array#includes() versus indexOf() === -1. On that note, I'm not sure if we have any list of minimum browser support that we are planning, or if we should run this library through something like Babel to make it ES5 compliant (and minify it, etc).

Also, not sure if we should log any REASON misses. Like, if somebody typed DataStoreError.GENERIC_ERRROR instead of DataStoreError.GENERIC_ERROR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can take a look at Array#includes(), but I've been hesitant to use APIs that I haven't had personal experience with on other platforms ... notably iOS WebKit (which is the target for lockbox-ios).

As far as minifying ... prove to me the size is an actual problem to deal with here, and not something that the consumers are better equiped for.

@linuxwolf
Copy link
Contributor Author

linuxwolf commented Feb 12, 2018

thinking on it more, logging a potentially bad error reason isn't that useful. As a developer, one ought to be testing the right error. Further, there's no good way to have it emit during the dev lifecycle but not emit in the user lifecycle.

Copy link

@kimberlythegeek kimberlythegeek left a comment

Choose a reason for hiding this comment

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

👍 Looks great!

@linuxwolf linuxwolf merged commit d8234f1 into mozilla-lockwise:master Feb 12, 2018
@ghost ghost removed the in progress We are actively working on it. label Feb 12, 2018
@linuxwolf linuxwolf deleted the 64-errors branch February 12, 2018 22:04
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.

3 participants