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

Handle errors related to KeySignature class instance methods #103

Open
meganindya opened this issue Mar 28, 2021 · 8 comments
Open

Handle errors related to KeySignature class instance methods #103

meganindya opened this issue Mar 28, 2021 · 8 comments
Labels
priority-low Low priority issues — not required soon

Comments

@meganindya
Copy link
Member

On branch musicutils, TypeScript ported file keySignature.ts has some of this methods including the constructor throw errors.

Handle with try catch calls to all such instances in other files.

@alfredhb
Copy link

This looks like it's still open, I'll add these try catch where keySignature is used. Is there a specific error handling pattern / method desired?

@meganindya
Copy link
Member Author

Yeah pls go ahead. Not anything in particular really — simple try { ... } catch (e) { ... }. Perhaps, look for a few code snippets to see how they've been used.

Do follow these guidelines though.

@alfredhb
Copy link

alfredhb commented Apr 14, 2021

Regarding uses of KeySignature, the only use in other files I found which wasn't wrapped in a try catch was its instantiation in currentPitch.ts (not including the py files in archive which I assume can be left as-is). I've added the try catch block to this instantiation and ensured that tests still pass. and linting does as well

Would you like me to add tests for this? I'm struggling to think of tests to add without mocking the KeySignature constructor to force it to throw an error

@meganindya
Copy link
Member Author

There are 11 methods (one of which is the constructor and another is a setter) which throw errors. The objective is to do a try-catch handling where error cases assign default values. The rest will throw errors anyway, like in the constructor of CurrentPitch - if KeySignature cannot be instantiated, CurrentPitch won't be instantiated.

However, the bulk of this issue is w.r.t. the test file corresponding to KeySignature in tests/. Please perform an error checking for all such methods which can throw error, using expect(...).toThrowError(...) if any case is missing. Also, wrap KeySignature instantiation in try-catch. I'm not sure, but sometimes jest reports a failure if all error possibilities aren't handled.

This is a rough idea, please report a list of what you think needs to be done re this issue in a comment ... I'll review that and you could then create a PR?

@alfredhb
Copy link

Hey sorry, something came up, and I'll need to step away from this issue at this time I apologise.

@meganindya meganindya transferred this issue from sugarlabs/musicblocks-v4-lib Nov 13, 2021
@meganindya meganindya added the priority-low Low priority issues — not required soon label Jan 15, 2022
@meganindya meganindya added this to the Release v4.2.0 milestone Feb 14, 2022
@nk183
Copy link

nk183 commented Mar 11, 2022

@meganindya, is this issue still there?

@meganindya
Copy link
Member Author

yeah go ahead.

@meganindya meganindya removed this from the Release Future milestone Nov 6, 2022
@KrishavRajSingh
Copy link

All I need to do is to add try-catch block on each function of keySignature.ts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-low Low priority issues — not required soon
Projects
Status: ⌛️ Ready
Development

No branches or pull requests

4 participants