Search code examples
scalawrapperthriftscrooge

How to properly instantiate a Thrift/Scrooge generated class in Scala


I would like to instantiate a crooge generated class (or trait, better said). Now since I can't instantiate a trait, I used a anonymous wrapper class to generate some test object I want to serealize:

val err = new ClientError{}

But I cannot set any properties to this object (or at least I don't know how). What's the proper way to do this? The background is I want to create an object, serialize it, send it, deserialize it and check if it worked, if the sample has the same properties. Thanks for any help!


Solution

  • There is an object ClientError, with an apply method. Just do

    val err = ClientError(whatever, fields, your, thrift, struct, has)