Commit 20147fd3 authored by Ghitha Dinan's avatar Ghitha Dinan

handle internal server error

parent 20f71e29
...@@ -81,20 +81,22 @@ class CustomExceptionHandler : ResponseEntityExceptionHandler() { ...@@ -81,20 +81,22 @@ class CustomExceptionHandler : ResponseEntityExceptionHandler() {
@ExceptionHandler(RuntimeException::class) @ExceptionHandler(RuntimeException::class)
fun handleRuntimeException(ex: Exception, request: WebRequest?): ResponseEntity<Any?>? { fun handleRuntimeException(ex: Exception, request: WebRequest?): ResponseEntity<Any?>? {
val response = ReturnData() val response = ReturnData()
response.success = false response.success = false
response.message = "Interval Server Error" response.message = "Terjadi kesalahan sistem. Silahkan ulangi beberapa saat lagi"
response.message = ex.message
var status = HttpStatus.INTERNAL_SERVER_ERROR var status = HttpStatus.INTERNAL_SERVER_ERROR
if (ex is BaseException) { if (ex is BaseException) {
response.message = "Terjadi kesalahan sistem. Silahkan ulangi beberapa saat lagi" ex.printStackTrace()
if (ex.status != status) {
response.message = ex.message
ex.data?.let { ex.data?.let {
response.data = it response.data = it
} }
status = ex.status status = ex.status
}
} else { } else {
return ResponseEntity(response, status) return ResponseEntity(response, status)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment