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

Change Result pattern to exceptions #395

Merged
merged 2 commits into from
Sep 17, 2024

Conversation

marlena-b
Copy link
Collaborator

Issue: #393

I refactored the code to use exceptions instead of the Result pattern for consistency with our existing codebase.

I also renamed order_side_effects to update_order_state for better clarity.

Copy link

netlify bot commented Sep 5, 2024

Deploy Preview for ecommerce-events failed.

Name Link
🔨 Latest commit d1c12af
🔍 Latest deploy log https://app.netlify.com/sites/ecommerce-events/deploys/66e822e926d22c0008fa14fa

if unavailable_products.any?
raise OrderHasUnavailableProducts.new(unavailable_products)
end
true
Copy link
Contributor

Choose a reason for hiding this comment

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

Service objects ideally should have "void" type, we shouldn't rely on the return value - it either raises exception or its success.

result = Orders::SubmitService.new(order_id: order_id, customer_id: customer_id).call

assert_equal result.status, :success
assert_equal true, Orders::SubmitService.new(order_id: order_id, customer_id: customer_id).call
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's try to test some actual effect of running this service object (read model value?) instead of testing it's return value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, thank you for your comments! :)

@andrzejkrzywda andrzejkrzywda merged commit a42c949 into master Sep 17, 2024
27 of 31 checks passed
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