Skip to content
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

Introduce ConnectionErrorType enum for modeling connection errors to hosts #1581

Merged
merged 15 commits into from
Mar 25, 2020
Merged

Introduce ConnectionErrorType enum for modeling connection errors to hosts #1581

merged 15 commits into from
Mar 25, 2020

Conversation

markfields
Copy link
Member

@markfields markfields commented Mar 20, 2020

Minimal fix for #1354. It's a non-breaking change so they can switch over from raw statusCode to the more semantic connectionError at their leisure.

  • TODO: Add/update tests, hence the Draft PR.

More thought could probably be put into the model here, probably in a later change:

  • Should 401 v. 403 be distinguished? Any other data to pass out to the host in this case? I have no idea how auth works here yet 😋
  • Other common/interesting status codes?
  • Other logic besides just checking status code to include in the logic to choose connectionError in Network.ts?
  • If we want the different error cases to hold different data, we can break IConnectionError up into other interfaces similarly to how IError is defined, and replace the class NetworkError with different specific implementations, maybe with a little factory method to abstract the differences from callers.

Also, I might propose some refactoring of OdspNetworkError in another change, it's also modeled a little strangely (e.g. passing in fake 400 status codes).

@markfields
Copy link
Member Author

Updated per Ruchika's request. Need to fix the tests.

packages/drivers/odsp-socket-storage/src/odspUtils.ts Outdated Show resolved Hide resolved
packages/loader/driver-utils/src/network.ts Outdated Show resolved Hide resolved
packages/drivers/odsp-socket-storage/src/odspUtils.ts Outdated Show resolved Hide resolved
packages/loader/driver-utils/src/network.ts Outdated Show resolved Hide resolved
packages/loader/driver-utils/src/network.ts Outdated Show resolved Hide resolved
packages/loader/driver-utils/src/network.ts Outdated Show resolved Hide resolved
@markfields markfields marked this pull request as ready for review March 24, 2020 17:19
@@ -643,13 +643,14 @@ export class DeltaManager extends EventEmitter implements IDeltaManager<ISequenc
replayFrom: from,
to,
});
const closeError: IConnectionError = {
Copy link
Member Author

Choose a reason for hiding this comment

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

@vladsud - This is interesting - the fact that someone can just instantiate an object adhering to the interface means they miss out on extending ErrorWithProps and Error. Not extending Error is probably ok since it's not thrown anyway, but it won't be logged properly without extending ErrorWithProps. Not sure how to enforce this, something to discuss... Worthy of an issue?

undefined /*statusCode*/,
undefined /*retryAfterSeconds*/,
"Online",
) as IGenericNetworkError;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to self: This is sloppy, I'd like to revisit this in a later change.

@markfields markfields merged commit 265b20a into microsoft:master Mar 25, 2020
@markfields markfields deleted the connection-errors branch April 2, 2020 18:46
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.

None yet

3 participants