Skip to content

Try overload resolution ambiquity #17

Open
@EliasJorgensen

Description

When i use Try.getOrElseThrow, i get the following error:
image

This is the code in question:

val flow = Try { flowDao.save(Flow(source.name, source.applicationId)) }
	.getOrElseThrow { FlowNameAlreadyInUse() }

This is my exception:

@ResponseStatus(HttpStatus.CONFLICT)
class FlowNameAlreadyInUse : RuntimeException()

I am using it the same way that i would throw an exception with java.util.Optional.getOrElseThrow, so i believe this to be a bug.

I can make it work by putting the exception in a lambda, but i believe this to be a bad solution, especially given that IntelliJ keeps suggesting me to remove the useless lambda.

val flow = Try { flowDao.save(Flow(source.name, source.applicationId)) }
	.getOrElseThrow { -> FlowNameAlreadyInUse() }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions