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

Improve EntityStreamSizeException message #2823

Merged
merged 2 commits into from Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -118,10 +118,12 @@ final case class EntityStreamSizeException(limit: Long, actualSize: Option[Long]

override def getMessage = toString

override def toString =
s"EntityStreamSizeException: actual entity size ($actualSize) exceeded content length limit ($limit bytes)! " +
s"You can configure this by setting `akka.http.[server|client].parsing.max-content-length` or calling `HttpEntity.withSizeLimit` " +
s"before materializing the dataBytes stream."
override def toString = {
s"EntityStreamSizeException: incoming entity size (${actualSize.getOrElse("while streaming")}) exceeded size limit ($limit bytes)! " +
"This may have been a parser limit (set via `akka.http.[server|client].parsing.max-content-length`), " +
"a decoder limit (set via `akka.http.routing.decode-max-size`), " +
"or a custom limit set with `withSizeLimit`."
}
}

case class RequestTimeoutException(request: HttpRequest, message: String) extends RuntimeException(message)
Expand Up @@ -1255,7 +1255,7 @@ class HttpServerSpec extends AkkaSpec(
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis.dilated))
.getCause
error shouldEqual EntityStreamSizeException(limit, Some(actualSize))
error.getMessage should include("exceeded content length limit")
error.getMessage should include("exceeded size limit")

responses.expectRequest()
responses.sendError(error.asInstanceOf[Exception])
Expand All @@ -1278,7 +1278,7 @@ class HttpServerSpec extends AkkaSpec(
.thrownBy(entity.dataBytes.runFold(ByteString.empty)(_ ++ _).awaitResult(100.millis.dilated))
.getCause
error shouldEqual EntityStreamSizeException(limit, None)
error.getMessage should include("exceeded content length limit")
error.getMessage should include("exceeded size limit")

responses.expectRequest()
responses.sendError(error.asInstanceOf[Exception])
Expand Down