35 lines
1.1 KiB
Kotlin
35 lines
1.1 KiB
Kotlin
package be.simplenotes.app.views
|
|
|
|
import be.simplenotes.app.utils.StaticFileResolver
|
|
import be.simplenotes.app.views.components.Alert
|
|
import be.simplenotes.app.views.components.alert
|
|
import kotlinx.html.a
|
|
import kotlinx.html.div
|
|
|
|
class ErrorView(staticFileResolver: StaticFileResolver) : View(staticFileResolver) {
|
|
|
|
enum class Type(val title: String) {
|
|
SqlTransientError("Database unavailable"),
|
|
NotFound("Not Found"),
|
|
Other("Error"),
|
|
}
|
|
|
|
fun error(errorType: Type) = renderPage(errorType.title, jwtPayload = null) {
|
|
div("container mx-auto p-4") {
|
|
when (errorType) {
|
|
Type.SqlTransientError -> alert(
|
|
Alert.Warning,
|
|
errorType.title,
|
|
"Please try again later",
|
|
multiline = true
|
|
)
|
|
Type.NotFound -> alert(Alert.Warning, errorType.title, "Page not found", multiline = true)
|
|
Type.Other -> alert(Alert.Warning, errorType.title)
|
|
}
|
|
div {
|
|
a(href = "/", classes = "btn btn-green") { +"Go back to the homepage" }
|
|
}
|
|
}
|
|
}
|
|
}
|