Skip to content

LG-12494: err gen method#10294

Merged
dawei-nava merged 5 commits intomainfrom
dwang/LG-12494_err_gen_method
Mar 26, 2024
Merged

LG-12494: err gen method#10294
dawei-nava merged 5 commits intomainfrom
dwang/LG-12494_err_gen_method

Conversation

@dawei-nava
Copy link
Contributor

@dawei-nava dawei-nava commented Mar 23, 2024

🎫 Ticket

Link to the relevant ticket:
LG-12494

🛠 Summary of changes

Refactoring ErrorGenerator. By creating POROs with single responsibilities. At top level, ErrorGenerator is responsible mostly to decide what error to bubble up and what errors to consolidate.

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

Existing test cases and manual testing for failure scenarios.

…anding.

changelog: Internal, Doc Auth, Refactor doc auth error generation.
@dawei-nava dawei-nava marked this pull request as ready for review March 23, 2024 14:09
unknown_fail_count = scan_for_unknown_alerts(response_info)

# check whether ID type supported
error = IdTypeErrorHandler.new.handle(response_info)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to keep redefining error? If not, I think it'd be clearer to name this id_error and the next image_error and so on. I think it would improve readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@night-jellyfish , changed. If you think from top down, then there should be no confusion, if you think from bottom up, yes, name them differently will makes it clearer.

end
end
def is_selfie_failure(error)
error == Errors::SELFIE_FAILURE
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I may not be following, but does this mean is_selfie_failure would return false if SELFIE_POOR_QUALITY or SELFIE_NOT_LIVE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@night-jellyfish , renamed the function, basically this is a case that we present a general selfie error.

end
end
end
def present_generic_selfie_error?(error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def present_generic_selfie_error?(error)
def is_generic_selfie_error?(error)

selfie_error = selfie_error_handler.handle(response_info)

# if selfie itself is ok, but we have selfie related error
if selfie_error_handler.present_generic_selfie_error?(selfie_error)
Copy link
Contributor

@amirbey amirbey Mar 26, 2024

Choose a reason for hiding this comment

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

Suggested change
if selfie_error_handler.present_generic_selfie_error?(selfie_error)
if selfie_error_handler.is_generic_selfie_error?(selfie_error)

i found it a challenge to know what is #present_generic_selfie_error? without looking at the method defintion

Comment on lines +327 to +328
alert_error = AlertErrorHandler.new(config: config, liveness_enabled: liveness_enabled).
handle(known_alert_error_count, response_info, selfie_error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
alert_error = AlertErrorHandler.new(config: config, liveness_enabled: liveness_enabled).
handle(known_alert_error_count, response_info, selfie_error)
alert_error_handler = AlertErrorHandler.new(config: config, liveness_enabled: liveness_enabled)
alert_error = alert_error_handler.handle(known_alert_error_count, response_info, selfie_error)

i think this would be more debuggable 🤔

unknown_fail_count = scan_for_unknown_alerts(response_info)

# check whether ID type supported
id_type_error = IdTypeErrorHandler.new.handle(response_info)
Copy link
Contributor

@amirbey amirbey Mar 26, 2024

Choose a reason for hiding this comment

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

Suggested change
id_type_error = IdTypeErrorHandler.new.handle(response_info)
id_type_error_handler = IdTypeErrorHandler.new
id_type_error = id_type_error_handler.handle(response_info)

i think this is more debuggable 🤔 ... kind of like how you implemented # check selfie error

Copy link
Contributor

@amirbey amirbey left a comment

Choose a reason for hiding this comment

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

Big thanks for taking this on Dawei 🙏🏿

I left a few minor suggestions

@dawei-nava dawei-nava merged commit 1ad37ab into main Mar 26, 2024
@dawei-nava dawei-nava deleted the dwang/LG-12494_err_gen_method branch March 26, 2024 21:17
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