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

New Feature: Fail when item is present #624

Closed
AlexandreGuidin opened this issue Jul 14, 2021 · 11 comments · Fixed by #627
Closed

New Feature: Fail when item is present #624

AlexandreGuidin opened this issue Jul 14, 2021 · 11 comments · Fixed by #627
Labels
enhancement New feature or request
Milestone

Comments

@AlexandreGuidin
Copy link
Contributor

AlexandreGuidin commented Jul 14, 2021

Hi everyone!

I would like to fail with a exception, if a Uni<> has a not null item.

i've coded this today:

profileRepository.findByEmail("[email protected]")
                .onItem().ifNotNull().call(p -> {throw new ValidationException("email", "already registered");})

But i didnt like it, it could be better

Idea of new API:

profileRepository.findByEmail("[email protected]")
                .onItem().ifNotNull().failWith(() -> new ValidationException("email", "already registered"))
@heubeck
Copy link
Collaborator

heubeck commented Jul 15, 2021

Why not using uni.onItem().ifNotNull().transformToUni(Uni.createFrom().failure(new ValidationException("email", "already registered"))?

@cescoffier
Copy link
Contributor

There is a failWith method in some groups. I believe we forgot to have it everywhere.

@jponge
Copy link
Member

jponge commented Jul 15, 2021

Let's link to #608

@jponge
Copy link
Member

jponge commented Jul 15, 2021

We indeed have a failWith operator, @AlexandreGuidin fancy a PR?

@AlexandreGuidin
Copy link
Contributor Author

AlexandreGuidin commented Jul 15, 2021

Why not using uni.onItem().ifNotNull().transformToUni(Uni.createFrom().failure(new ValidationException("email", "already registered"))?

That's better than the first option!

We indeed have a failWith operator, @AlexandreGuidin fancy a PR?

I've never contributed to a open-source project, but i could try, it should be simple 👀

@AlexandreGuidin
Copy link
Contributor Author

Ok, i've cloned the repo and add some code/tests, it works, how contributions works ? I need write permission to push it

@jponge
Copy link
Member

jponge commented Jul 15, 2021

You need to open a PR from your (non-main) branch to this repository

@AlexandreGuidin
Copy link
Contributor Author

AlexandreGuidin commented Jul 15, 2021

Everyone has access to push a new branch to the origin ?

➜  smallrye-mutiny git:(feature/uninotnull-fail) gpsup
ERROR: Permission to smallrye/smallrye-mutiny.git denied to AlexandreGuidin.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
the alias gpsup means => git push --set-upstream origin feature/uninotnull-fail

I've checked my SSH with other project, it's working 😄

@jponge
Copy link
Member

jponge commented Jul 16, 2021

You need to push to your own fork, you don't have permissions on this repo.

@AlexandreGuidin
Copy link
Contributor Author

PR Created #627

@jponge jponge added the enhancement New feature or request label Jul 16, 2021
@jponge jponge added this to the 1.0.0 milestone Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants