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
Collaborator

@qwwdfsad qwwdfsad commented Jul 6, 2022

Fixes #1266

@qwwdfsad qwwdfsad requested a review from sandwwraith July 6, 2022 15:44
@qwwdfsad
Copy link
Collaborator 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 July 7, 2022 09:47
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

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

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
Collaborator Author

@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 July 11, 2022 11:10
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.

3 participants