Add detailed room create debug steps and exception header
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 27s
This commit is contained in:
@@ -189,13 +189,23 @@ class Rooms(
|
|||||||
response.setHeader("X-Room-Create-Step", "member_ok")
|
response.setHeader("X-Room-Create-Step", "member_ok")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (debugAuth == "1") {
|
||||||
|
response.setHeader("X-Room-Create-Step", "check_duplicate")
|
||||||
|
}
|
||||||
if (roomRepo.existsByPropertyIdAndRoomNumber(propertyId, request.roomNumber)) {
|
if (roomRepo.existsByPropertyIdAndRoomNumber(propertyId, request.roomNumber)) {
|
||||||
throw ResponseStatusException(HttpStatus.CONFLICT, "Room number already exists for property")
|
throw ResponseStatusException(HttpStatus.CONFLICT, "Room number already exists for property")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debugAuth == "1") {
|
||||||
|
response.setHeader("X-Room-Create-Step", "load_property")
|
||||||
|
}
|
||||||
val property = propertyRepo.findById(propertyId).orElseThrow {
|
val property = propertyRepo.findById(propertyId).orElseThrow {
|
||||||
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
ResponseStatusException(HttpStatus.NOT_FOUND, "Property not found")
|
||||||
}
|
}
|
||||||
|
if (debugAuth == "1") {
|
||||||
|
response.setHeader("X-Room-Create-Step", "resolve_room_type")
|
||||||
|
}
|
||||||
val roomType = resolveRoomType(propertyId, request)
|
val roomType = resolveRoomType(propertyId, request)
|
||||||
|
|
||||||
val room = Room(
|
val room = Room(
|
||||||
@@ -209,12 +219,22 @@ class Rooms(
|
|||||||
notes = request.notes
|
notes = request.notes
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (debugAuth == "1") {
|
||||||
|
response.setHeader("X-Room-Create-Step", "save_room")
|
||||||
|
}
|
||||||
val saved = roomRepo.save(room).toRoomResponse()
|
val saved = roomRepo.save(room).toRoomResponse()
|
||||||
if (debugAuth == "1") {
|
if (debugAuth == "1") {
|
||||||
response.setHeader("X-Room-Create-Step", "saved")
|
response.setHeader("X-Room-Create-Step", "saved")
|
||||||
}
|
}
|
||||||
roomBoardEvents.emit(propertyId)
|
roomBoardEvents.emit(propertyId)
|
||||||
return saved
|
return saved
|
||||||
|
} catch (ex: Exception) {
|
||||||
|
if (debugAuth == "1") {
|
||||||
|
val msg = ex.message?.take(200) ?: ""
|
||||||
|
response.setHeader("X-Room-Create-Exception", "${ex::class.java.simpleName}:$msg")
|
||||||
|
}
|
||||||
|
throw ex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/{roomId}")
|
@PutMapping("/{roomId}")
|
||||||
|
|||||||
Reference in New Issue
Block a user