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

chore(errors): add custom error classes #508

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

jriffs
Copy link
Contributor

@jriffs jriffs commented Jun 19, 2023

Description

Added custom error classes GRPCNotSupportedError and HTTPNotSupportedError and updated the following classes to use the new custom errors
-src/implementation/Client/HTTPClient/configuration.ts
-src/implementation/Client/HTTPClient/proxy.ts
-src/implementation/Server/GRPCServer/actor.ts

#297

Signed-off-by: jriffs <mayjriffs97@gmail.com>
@jriffs jriffs requested review from a team as code owners June 19, 2023 17:46
src/version.ts Outdated Show resolved Hide resolved
}

registerActor<T extends AbstractActor>(_cls: Class<T>): Promise<void> {
throw new Error("GRPC is currently not supported.");
Copy link
Member

Choose a reason for hiding this comment

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

There might be more such errors now introduced in some PRs like #485

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've searched the repo and there doesn't seem to be anymore files with those errors or similar errors

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I have found and updated it.
Quick question0- Do i create a new folder errors in the test directory to place the unit test files or do i just add them to an existing folder in the same test directory

Copy link
Member

@shubham1172 shubham1172 Jun 20, 2023

Choose a reason for hiding this comment

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

They should be a part of https://github.com/dapr/js-sdk/tree/main/test/unit/<an-existing-folder> to test if components return the correct error, and also in https://github.com/dapr/js-sdk/tree/main/test/unit/errors to test the error itself.

Signed-off-by: jriffs <mayjriffs97@gmail.com>
@codecov
Copy link

codecov bot commented Jun 20, 2023

Codecov Report

Merging #508 (f365bbd) into main (0d16244) will decrease coverage by 0.47%.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##             main     #508      +/-   ##
==========================================
- Coverage   35.69%   35.22%   -0.47%     
==========================================
  Files          87       90       +3     
  Lines       10125    10142      +17     
  Branches      414      415       +1     
==========================================
- Hits         3614     3573      -41     
- Misses       6452     6503      +51     
- Partials       59       66       +7     
Impacted Files Coverage Δ
src/implementation/Client/GRPCClient/workflow.ts 30.00% <12.50%> (+7.77%) ⬆️
src/implementation/Client/HTTPClient/workflow.ts 12.69% <14.28%> (+1.40%) ⬆️
.../implementation/Client/HTTPClient/configuration.ts 42.85% <20.00%> (+9.52%) ⬆️
src/implementation/Server/GRPCServer/actor.ts 42.85% <20.00%> (+9.52%) ⬆️
src/errors/GRPCNotSupportedError.ts 33.33% <33.33%> (ø)
src/errors/HTTPNotSupportedError.ts 33.33% <33.33%> (ø)
src/implementation/Client/HTTPClient/proxy.ts 75.00% <50.00%> (+8.33%) ⬆️
src/errors/PropertyRequiredError.ts 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

@jriffs jriffs force-pushed the jriffs/custom-errors branch from cfd3823 to de37df0 Compare June 20, 2023 19:50
Copy link
Member

Choose a reason for hiding this comment

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

This file has appeared again, I wonder is your IDE doing some magic 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shubham1172 I think it is doing some magic lol 😅, I suspect it does this when i run npm run pretty-fix command, but I'll be on the lookout next time. Could you please 🙏 give me a few pointers on how to resolve the code coverage issue, how do i test that each component returns the right 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.

@shubham1172 still waiting on your response sir 😇

Copy link
Member

Choose a reason for hiding this comment

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

Hi @jriffs, sorry this got lost in my GitHub notifications, thanks for pinging. For code coverage, I think it is okay to skip testing "GRPCNotSupportedError" or "HTTPNotSupportedError" since we usually do not write tests for unimplemented code anyway.

For PropertyRequiredError, we can create unit tests under test/unit/http, for e.g. workflow.ts and with a similar pattern like HttpServerImpl.test.ts, we can expect methods to throw a certain error.

@@ -23,7 +24,7 @@ export default class GRPCClientWorkflow implements IClientWorkflow {
}

get(_instanceId: string, _workflowComponent?: string | undefined): Promise<WorkflowGetResponseType> {
throw new Error("Method not implemented.");
throw new MethodNotImplementedError();
Copy link
Member

Choose a reason for hiding this comment

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

This can be same as GrpcNotSupportedError, I don't think we will need MethodNotImplemented error then.

Copy link
Member

Choose a reason for hiding this comment

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

Hi @jriffs, sorry this got lost in my GitHub notifications, thanks for pinging. For code coverage, I think it is okay to skip testing "GRPCNotSupportedError" or "HTTPNotSupportedError" since we usually do not write tests for unimplemented code anyway.

For PropertyRequiredError, we can create unit tests under test/unit/http, for e.g. workflow.ts and with a similar pattern like HttpServerImpl.test.ts, we can expect methods to throw a certain error.

Signed-off-by: jriffs <mayjriffs97@gmail.com>
@jriffs jriffs force-pushed the jriffs/custom-errors branch from de37df0 to f365bbd Compare July 4, 2023 23:11
@jriffs
Copy link
Contributor Author

jriffs commented Jul 10, 2023

Hi @shubham1172 , i just wanted to ask if there were any problems with the PR, if there are none, i was wondering if you could maybe assign me to a new issue so i can get working on that.
Thank you.

@shubham1172
Copy link
Member

Thanks @jriffs, leaving it open for some time to get more eyes. Meanwhile you could pick up the good first issue from the next milestone https://github.com/dapr/js-sdk/milestone/13 :)

@shubham1172 shubham1172 changed the title fixing errors from earlier pull request chore(errors): add custom error classes Jul 11, 2023
@shubham1172 shubham1172 added this pull request to the merge queue Jul 11, 2023
Merged via the queue into dapr:main with commit 801847c Jul 11, 2023
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.

3 participants