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

How to debug "Cannot find JsonWriter or JsonFormatter type class" errors #323

Open
eswenson1 opened this issue Dec 4, 2019 · 0 comments

Comments

@eswenson1
Copy link

I've been trying for hours to get some code to compile and about to give up on spray-json as I'm having no luck. I'm trying to get rid of the error:

Error:(18, 24) Cannot find JsonWriter or JsonFormat type class for com.intertrust.modulus.services.audit.Event
        val result = e.toJson

I've used spray-json for years and am always confounded by errors such as this, and seek some methodology for debugging these and isolating WHY I get these occasionally when I'm pretty certain that I have implicit json formatters in-scope for all the case classes that extend the base trait (here Event).

When the hierarchy is:

    trait Event extends Product with Serializable 
    sealed trait AccountEvent extends Event
    case class AccountAdded(name: String, password: String) extends AccountEvent
    case class AccountDeleted(name: String) extends AccountEvent
    case class AccountPasswordChanged(name: String, password: String) extends AccountEvent
    sealed trait FooEvent extends Event
    case class FooEvent1() extends FooEvent

The compiler should be able to find that the ONLY types that extend Event are those case classes (since the trait from which they derive is sealed). So why can't it find the implicit jsonFormatter I have defined in a trait that is extended by the class in which the error is occurring?

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

No branches or pull requests

1 participant