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

fix(typo): new api for ErrorBuilder in 5.x #252

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

xiaoshihou514
Copy link

By the way, is there a shorthand for overriding the DefaultErrorBuilder's build method, but keep all the implemented goodies?

class ErrBuilder extends DefaultErrorBuilder with ErrorBuilder[EnrichedErr] with MatchParserDemand {
    override def build(pos: String, source: Option[String], lines: Seq[String]): MyError =
        MyError(pos, source, lines)
}

The types are a bit awkward here, should I be using an implicit conversion here maybe?

@j-mie6 j-mie6 merged commit 67ec828 into j-mie6:staging/5.0 Jan 17, 2025
15 checks passed
@j-mie6
Copy link
Owner

j-mie6 commented Jan 17, 2025

Nope, you can't override associated types

@xiaoshihou514
Copy link
Author

So I would have to write the boilerplate of delegating everything to a DefaultErrorBuilder?

@j-mie6
Copy link
Owner

j-mie6 commented Jan 19, 2025

yes, the methods are exposed via the companion for DefaultErrorBuilder. But chances are you just want to preserve it as pure data anyway. Plus, rendering an error as a string can be done much more efficiently if you don't use the DefaultErrorBuilder methods, which can't use StringBuilder

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