Re: [scalatest-users] Exception messages not printed out with stdout reporter

12 views
Skip to first unread message
Message has been deleted

Bill Venners

unread,
Nov 22, 2016, 5:27:11 PM11/22/16
to scalate...@googlegroups.com
Hi Sean,

I'm not sure toString is propagated to message. There's a field called message on Throwable, which is what ScalaTest displays (by calling getMessate).

BIll

On Tue, Nov 22, 2016 at 3:53 PM, Sean Callahan <sean.cal...@gmail.com> wrote:
I have the following custom exception 

class HttpRequestException(val response: HttpResponse) extends Throwable {
...
  override def toString: String = {
    s"Received unexpected status code. \n Status Code: [${response.status}] \n Body: $body \n Headers: $headers"
  }
}

When this exception is thrown along the stack in my tests, the stdout "-o" reporter only shows the following in the output.

  - test that fails *** FAILED ***
    com.twitter.dataproducts.clients.http.HttpRequestException:
    at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:25)
    at com.twitter.dataproducts.clients.akka.Flows$$anonfun$checkResponseForError$1.apply(Flows.scala:22)
    at akka.stream.impl.fusing.Map$$anon$8.onPush(Ops.scala:43)

It seems that the exception message is not getting to the proper place here. I am sure I am doing something wrong. Any help would be appreciated.

--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalatest-users@googlegroups.com
To unsubscribe from this group, send email to
scalatest-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Bill Venners
Artima, Inc.
http://www.artima.com

Sean Callahan

unread,
Nov 28, 2016, 1:09:30 PM11/28/16
to scalatest-users
When working with this, I also have tried to override getMessage on Throwable with the same implementation as the override from toString above, and the result is the same. 

Sean Callahan

unread,
Nov 28, 2016, 1:27:47 PM11/28/16
to scalatest-users
This seems to be the line for the StringReporter. I am trying to dig in to see why it's not working properly, but that will take me some time. 

Reply all
Reply to author
Forward
0 new messages