All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.javalin.http.HttpResponseException.kt Maven / Gradle / Ivy

/*
 * Javalin - https://javalin.io
 * Copyright 2017 David Åse
 * Licensed under Apache 2.0: https://github.com/tipsy/javalin/blob/master/LICENSE
 */

package io.javalin.http

open class HttpResponseException @JvmOverloads constructor(val status: Int, message: String, val details: Map = mapOf()) : RuntimeException(message)

class RedirectResponse @JvmOverloads constructor(
    status: Int = HttpCode.FOUND.status,
    message: String = "Redirected",
    details: Map = mapOf()
) : HttpResponseException(status, message, details)


class BadRequestResponse @JvmOverloads constructor(
    message: String = "Bad request",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.BAD_REQUEST.status, message, details)

class UnauthorizedResponse @JvmOverloads constructor(
    message: String = "Unauthorized",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.UNAUTHORIZED.status, message, details)

class ForbiddenResponse @JvmOverloads constructor(
    message: String = "Forbidden",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.FORBIDDEN.status, message, details)

class NotFoundResponse @JvmOverloads constructor(
    message: String = "Not found",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.NOT_FOUND.status, message, details)

class MethodNotAllowedResponse @JvmOverloads constructor(
    message: String = "Method not allowed",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.METHOD_NOT_ALLOWED.status, message, details)

class ConflictResponse @JvmOverloads constructor(
    message: String = "Conflict",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.CONFLICT.status, message, details)

class GoneResponse @JvmOverloads constructor(
    message: String = "Gone",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.GONE.status, message, details)

class InternalServerErrorResponse @JvmOverloads constructor(
    message: String = "Internal server error",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.INTERNAL_SERVER_ERROR.status, message, details)

class BadGatewayResponse @JvmOverloads constructor(
    message: String = "Bad gateway",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.BAD_GATEWAY.status, message, details)

class ServiceUnavailableResponse @JvmOverloads constructor(
    message: String = "Service unavailable",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.SERVICE_UNAVAILABLE.status, message, details)

class GatewayTimeoutResponse @JvmOverloads constructor(
    message: String = "Gateway timeout",
    details: Map = mapOf()
) : HttpResponseException(HttpCode.GATEWAY_TIMEOUT.status, message, details)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy