Skip to content

Avoid failing rgba API #2838

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

Merged
merged 3 commits into from
Dec 6, 2023
Merged

Avoid failing rgba API #2838

merged 3 commits into from
Dec 6, 2023

Conversation

ethanshar
Copy link
Collaborator

Description

Avoid failing Colors.rgba API on invalid input to avoid app crashes

Changelog

Avoid failing Colors.rgba API on invalid input to avoid app crashes

Additional info

@ethanshar ethanshar requested a review from M-i-k-e-l December 6, 2023 10:00
@@ -129,7 +130,8 @@ export class Colors {
blue = validateRGB(p3!);
opacity = p4;
} else {
throw new Error('rgba can work with either 2 or 4 arguments');
LogService.error('Colors.rgba fail due to invalid arguments');
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should be failed (also in tests)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean should be failed?
LogService.error doesn't throw an error

const SYSTEM_COLORS = ['grey', 'white', 'black'];
const GetColorsByHexOptions = {validColors: SYSTEM_COLORS};

describe('style/Colors', () => {
const logServiceSpy = jest.spyOn(LogService, 'error');
// jest.mock('../../services/LogService');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can be deleted

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

true

@ethanshar ethanshar enabled auto-merge (squash) December 6, 2023 11:36
@ethanshar ethanshar merged commit dcbece0 into master Dec 6, 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.

2 participants