Skip to content

Commit

Permalink
Better stack trace on import
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlSjostrand committed Jan 28, 2019
1 parent 31ea42d commit 20a591b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/scala/se/nimsa/sbx/app/routing/ImportRoutes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ trait ImportRoutes {
complete((httpStatus, metaData.image))
}
case Failure(failure) =>
failure.printStackTrace()
val status = failure match {
case _: DicomStreamException => BadRequest
case _ => InternalServerError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ trait DicomStreamOps {
scheduleTask(30.seconds) {
storage.deleteByName(Seq(tempPath)) // delete temp file once file system has released handle
}
if (!t.isInstanceOf[DicomStreamException]) throw new DicomStreamException(t.getMessage) else throw t

// The actual cause of failure, in the case of DICOM exceptions, may be hidden deep in the stack trace. Find the deepest such element. If not return the top one.
def linearize(t: Throwable): List[Throwable] = if (t.getCause == null || t == t.getCause) t :: Nil else t :: linearize(t.getCause)
throw linearize(t)
.filter(_.isInstanceOf[DicomStreamException])
.lastOption
.getOrElse(new DicomStreamException(t.getMessage))
}
}
}
Expand Down

0 comments on commit 20a591b

Please sign in to comment.