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

Make missing field exception public #1983

Merged
merged 4 commits into from Jul 11, 2022
Merged

Make missing field exception public #1983

merged 4 commits into from Jul 11, 2022

Conversation

qwwdfsad
Copy link
Member

@qwwdfsad qwwdfsad commented Jul 6, 2022

Fixes #1266

@qwwdfsad qwwdfsad requested a review from sandwwraith Jul 6, 2022
@qwwdfsad
Copy link
Member Author

qwwdfsad commented Jul 6, 2022

I still cannot wrap my head around the proper solution for #1930, so it's unlikely to fit into 1.4.0 timeline

@qwwdfsad qwwdfsad requested a review from shanshin Jul 7, 2022
val missedMessages = messages.filter { !exception.message!!.contains(it) }
private inline fun assertFailsWithMessages(fields: List<String>, block: () -> Unit) {
val exception = assertFailsWith(MissingFieldException::class, null, block)
val missedMessages = fields.filter { !exception.message!!.contains(it) }
Copy link
Contributor

@shanshin shanshin Jul 7, 2022

Choose a reason for hiding this comment

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

M.b. missedFields?
Such a check is not very reliable !exception.message!!.contains(it), maybe always put names in single quotes and check !exception.message!!.contains("'$it'")

@sandwwraith
Copy link
Member

sandwwraith commented Jul 8, 2022

What about UnknownFieldException? It should be easier to expose. We can handle JSON exceptions later.

…gFieldsExceptionTest.kt

Co-authored-by: Leonid Startsev <sandwwraith@users.noreply.github.com>
@qwwdfsad
Copy link
Member Author

qwwdfsad commented Jul 11, 2022

@sandwwraith I found UnknownFieldException particularly useless -- index itself has no meaningful information and everything else is missing right now. So it should be reworked along with a plugin, prior to that there is not much sense to make this exception public

@qwwdfsad qwwdfsad merged commit 4524b65 into dev Jul 11, 2022
@qwwdfsad qwwdfsad deleted the public-exceptions branch Jul 11, 2022
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.

None yet

3 participants