Skip to content

Commit b545a62

Browse files
committed
feat: Print error message if Room loading fails
1 parent 02620c7 commit b545a62

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/views/room/RoomDetails.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const room = ref<RoomDTO | null>(null);
1717
const roomAvailability = ref<RoomAvailabilityListDTO | null>(null);
1818
const auth = useAuthStore();
1919
const loading = ref(false);
20+
const error = ref('');
2021
2122
onMounted(() => { auth.checkLocalStorage(); });
2223
onMounted(() => loadRoom());
@@ -29,6 +30,7 @@ const loadRoom = () => {
2930
RoomAPI.findById(roomId).then((res: AxiosResponse<RoomDTO>) => {
3031
room.value = res.data;
3132
}).catch((err: AxiosError) => {
33+
error.value = (err.response?.data as { error: string })?.error ?? "An unknown error occurred.";
3234
console.error(err);
3335
}).finally(() => {
3436
loading.value = false;
@@ -58,6 +60,9 @@ const gotoReservation = () => {
5860
<div v-if="loading">
5961
<ProgressBar mode="indeterminate" style="height: 6px"></ProgressBar>
6062
</div>
63+
64+
<Message v-show="error.length > 0" style="margin: 7px;" severity="error" size="medium" variant="simple">{{ error }}</Message>
65+
6166
<div v-if="room">
6267
<h2>{{ room.name }}</h2>
6368
<p>{{ room.description }}</p>

0 commit comments

Comments
 (0)