Skip to content

Commit

Permalink
remove unreachable error response logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern committed Nov 1, 2023
1 parent 415e968 commit af316bb
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions src/main/scala/controllers/ApiHelpController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,13 @@ import io.swagger.core.filter.SpecFilter
import io.swagger.models.Swagger
import io.swagger.util.Json
import javax.inject.Inject
import javax.xml.bind.annotation._
import play.api.Logger
import play.api.http.ContentTypes
import play.api.mvc._
import play.modules.swagger.SwaggerPlugin

import scala.jdk.CollectionConverters._

object ErrorResponse {
val ERROR = 1
val WARNING = 2
val INFO = 3
val OK = 4
val TOO_BUSY = 5
}

class ErrorResponse(@XmlElement var code: Int, @XmlElement var message: String) {
def this() = this(0, null)

@XmlTransient
def getCode: Int = code

def setCode(code: Int) = this.code = code

def getType: String = code match {
case ErrorResponse.ERROR => "error"
case ErrorResponse.WARNING => "warning"
case ErrorResponse.INFO => "info"
case ErrorResponse.OK => "ok"
case ErrorResponse.TOO_BUSY => "too busy"
case _ => "unknown"
}

def getMessage: String = message

def setMessage(message: String) = this.message = message
}

class ApiHelpController @Inject() (components: ControllerComponents, val swaggerPlugin: SwaggerPlugin)
extends AbstractController(components) with SwaggerBaseApiController {

Expand All @@ -73,13 +42,7 @@ class ApiHelpController @Inject() (components: ControllerComponents, val swagger
val host: String = swaggerPlugin.config.host
val apiListing: Swagger = getApiListing(path, host)
val response: String = toJsonString(apiListing)
Option(response) match {
case Some(help) => returnValue(help)
case None =>
val msg = new ErrorResponse(500, "api listing for path " + path + " not found")
Logger("swagger").error(msg.message)
InternalServerError(ByteString(toJsonString(msg))).as(JSON)
}
returnValue(response)
}
}

Expand Down

0 comments on commit af316bb

Please sign in to comment.