8000 fix: make YamlMap::get throws IncorrectTypeException with clear message by XYZboom · Pull Request #699 · charleskorn/kaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: make YamlMap::get throws IncorrectTypeException with clear message #699

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

XYZboom
Copy link
@XYZboom XYZboom commented May 3, 2025

The "clear error message" fix for issue #697

@XYZboom XYZboom changed the title Make YamlMap::get throws IncorrectTypeException with clear message fix: make YamlMap::get throws IncorrectTypeException with clear message May 3, 2025
// if the value is not the given type,
// throws IncorrectTypeException with a clear message instead of ClassCastException.
return node as? T ?: throw IncorrectTypeException(
"Expected element to be ${T::class.simpleName} but is ${node::class.simpleName}",
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of using the class names, could you please use the plain English names instead (eg. instead of "YamlList", use "list", instead of "YamlMap", use "map" etc.)

Copy link
Author
@XYZboom XYZboom May 5, 2025

Choose a reason for hiding this comment

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

I noticed that class name is used here(https://github.com/charleskorn/kaml/blob/main/src/commonMain/kotlin/com/charleskorn/kaml/YamlNode.kt#L304), so I just want to keep it consistent with here. Do we need to make some changes here at YamlNode.kt:Line 304?

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
0