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

Throw exceptions instead of using status codes #150

Merged
merged 1 commit into from
Oct 16, 2023
Merged

Conversation

dimaryaz
Copy link
Contributor

No description provided.

@dimaryaz dimaryaz requested a review from drernie October 16, 2023 18:22
@dimaryaz dimaryaz self-assigned this Oct 16, 2023
catch (Exception e) {
log.error("publish failed: ${e.getMessage()}", pkg.meta)
}
publish()
} else {
log.info("not publishing: ${pkg} [unsuccessful session]")
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 think this should throw an exception, too, but I don't know which one

Copy link
Member

Choose a reason for hiding this comment

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

Some options

Sync­Failed­Exception

Protocol­Exception

Server­Exception

Maybe define your own?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of those are for very specific Java features, so doesn't seem right. They all inherit from IOException, so could just use that one.

But, IOException is for failures that the user has no control over (network failures, etc.) - while here, it looks like the user should've checked that the session is valid. If that's the case, then IllegalStateException might be more appropriate.

// NOTE: push does NOT update local registry
expect:
makeWriteProduct().pkg.install() // try to merge existing metadata
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This actually fails!

But the existing test doesn't check the status code.

when:
makeWriteProduct(skip_meta) // still fails on implicit metadata
then:
thrown(com.quiltdata.quiltcore.workflows.WorkflowException)
Copy link
Member

Choose a reason for hiding this comment

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

I see you already defined one here.

quiltcore.package.PushException?

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 actually never created our own PushException, but just used java.io.IOException. Still don't know what's best.

Copy link
Member

Choose a reason for hiding this comment

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

java.io.IOException is fine. The user shouldn't really have control over the Session.

@dimaryaz dimaryaz merged commit d22cff6 into main Oct 16, 2023
11 checks passed
@dimaryaz dimaryaz deleted the better_exceptions branch October 16, 2023 18:46
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