-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from WikiWatershed/ki/improve-error-reporting
Improve client-side error response messages Connects #69
- Loading branch information
Showing
4 changed files
with
73 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.wikiwatershed.mmw.geoprocessing | ||
|
||
import akka.http.scaladsl.model._ | ||
import akka.http.scaladsl.server._ | ||
import StatusCodes.{BadRequest,InternalServerError} | ||
import Directives._ | ||
|
||
sealed trait GeoprocessingException extends Exception | ||
case class MissingTargetRasterException() extends GeoprocessingException() | ||
case class MissingVectorCRSException() extends GeoprocessingException() | ||
case class MissingVectorException() extends GeoprocessingException() | ||
case class InvalidOperationException(val message: String) extends GeoprocessingException() | ||
case class UnknownCRSException(val crs: String) extends GeoprocessingException() | ||
|
||
trait ErrorHandler { | ||
val geoprocessingExceptionHandler = ExceptionHandler { | ||
case InvalidOperationException(e) => { | ||
println(s"Invalid operation type: $e") | ||
complete(HttpResponse(BadRequest, entity = e)) | ||
} | ||
case MissingTargetRasterException() => { | ||
println("Input error: Missing required targetRaster") | ||
complete(HttpResponse(BadRequest, entity = "Missing required targetRaster")) | ||
} | ||
case MissingVectorCRSException() => { | ||
println("Input error: Missing required vectorCRS") | ||
complete(HttpResponse(BadRequest, entity = "Missing required vectorCRS")) | ||
} | ||
case MissingVectorException() => { | ||
println(s"Input error: Missing required vector") | ||
complete(HttpResponse(BadRequest, entity = "Missing required vector")) | ||
} | ||
case UnknownCRSException(crs) => { | ||
println(s"Unknown CRS error: $crs") | ||
complete(HttpResponse(BadRequest, entity = "Unknown CRS")) | ||
} | ||
case e: Exception => { | ||
println(s"Exception: $e") | ||
complete(HttpResponse(InternalServerError, entity = s"$e")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters