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

Allow to get source position of unmarshal error #760

Closed
wants to merge 2 commits into from

Conversation

rhysd
Copy link

@rhysd rhysd commented Jun 30, 2021

Fixes #759

With this PR, error instances in TypeError.Errors know their source positions. Previously the field was string slice, but now it is slice of struct of message, line and column so that the caller can know where each error occurred exactly.

@andig
Copy link

andig commented Sep 18, 2022

It would be absolutely fantastic to have this capability.

/cc @niemeyer is this blocked in any way? Could a small sponsoring help to move this forward?

@andig
Copy link

andig commented Sep 18, 2022

@rhysd I think there is a second case that's not handled. When decode panics, it moves into handleErr:

func handleErr(err *error) {
	if v := recover(); v != nil {
		if e, ok := v.(yamlError); ok {
			*err = e.err
		} else {
			panic(v)
		}
	}
}

Does yamlError need line information, too?

@rhysd
Copy link
Author

rhysd commented Sep 18, 2022

It would be necessary. But I don't have enough time to update this branch for now.

@andig
Copy link

andig commented Sep 18, 2022

@rhysd Maybe you could take a look- forked your PR and added terminal failures with line numbers.

@rhysd
Copy link
Author

rhysd commented Sep 19, 2022

Looks good to me. Thank you for improving this branch. I'm closing this in favor of #901.

@rhysd rhysd closed this Sep 19, 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.

Feature request: Unmarshal error with source position
2 participants