Skip to content

Commit bbc0c62

Browse files
committed
WIP
- Try catch around server error responses, in case we try to set headers after body is sent.
1 parent c6f8705 commit bbc0c62

File tree

3 files changed

+56
-19
lines changed

3 files changed

+56
-19
lines changed

api/api/V1/responseUtil.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,16 @@ export const serverErrorResponse = async (
192192
error.stack,
193193
);
194194
}
195-
return someResponse(
196-
response,
197-
HttpStatusCode.ServerError,
198-
messageOrData,
199-
data,
200-
);
195+
try {
196+
return someResponse(
197+
response,
198+
HttpStatusCode.ServerError,
199+
messageOrData,
200+
data,
201+
);
202+
} catch (e) {
203+
log.error(e);
204+
}
201205
};
202206

203207
export default {

api/api/customErrors.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@ function errorHandler(
4646
// FIXME - leave this in for sidekick etc, since currently it expects a 'message' error response.
4747
delete error.message;
4848
}
49-
return someResponse(
50-
response,
51-
(err as CustomError).statusCode,
52-
err.message,
53-
{
54-
...error,
55-
requestId,
56-
},
57-
);
49+
try {
50+
return someResponse(
51+
response,
52+
(err as CustomError).statusCode,
53+
err.message,
54+
{
55+
...error,
56+
requestId,
57+
},
58+
);
59+
} catch (error) {
60+
log.error(error);
61+
}
5862
}
5963
return serverErrorResponse(
6064
request,

browse-next/src/views/RecordingView.vue

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,20 @@ onMounted(async () => {
912912
});
913913
914914
const visitDurationString = computed<string>(() => {
915+
let date;
916+
if (recording.value) {
917+
date = DateTime.fromJSDate(new Date(recording.value.recordingDateTime));
918+
} else {
919+
date = DateTime.fromJSDate(new Date());
920+
}
921+
922+
const now = new Date();
923+
let dateString;
924+
if (date.year != now.getFullYear()) {
925+
dateString = date.toFormat("d MMM yy");
926+
} else {
927+
dateString = date.toFormat("d MMM");
928+
}
915929
if (selectedVisit.value && locationContext && locationContext.value) {
916930
const visit = selectedVisit.value as ApiVisitResponse;
917931
const duration = visitDuration(visit, !!isDesktop.value);
@@ -924,12 +938,26 @@ const visitDurationString = computed<string>(() => {
924938
// If visitStart has the same suffix as visitEnd, omit it.
925939
visitStart = visitStart.replace("am", "").replace("pm", "");
926940
}
927-
return `${visitStart}&ndash;${visitEnd} (${duration})`;
941+
return `<strong>${dateString}</strong>, ${visitStart}&ndash;${visitEnd} (${duration})`;
928942
}
929-
return "";
943+
return `<strong>${dateString}</strong>`;
930944
});
931945
932946
const recordingDurationString = computed<string>(() => {
947+
let date;
948+
if (recording.value) {
949+
date = DateTime.fromJSDate(new Date(recording.value.recordingDateTime));
950+
} else {
951+
date = DateTime.fromJSDate(new Date());
952+
}
953+
954+
const now = new Date();
955+
let dateString;
956+
if (date.year != now.getFullYear()) {
957+
dateString = date.toFormat("d MMM yy");
958+
} else {
959+
dateString = date.toFormat("d MMM");
960+
}
933961
if (recording.value && locationContext && locationContext.value) {
934962
const rec = recording.value as ApiRecordingResponse;
935963
const durationMs = rec.duration * 1000;
@@ -951,9 +979,9 @@ const recordingDurationString = computed<string>(() => {
951979
// If visitStart has the same suffix as visitEnd, omit it.
952980
visitStart = visitStart.replace("am", "").replace("pm", "");
953981
}
954-
return `${visitStart}&ndash;${visitEnd} (${duration})`;
982+
return `<strong>${dateString}</strong>, ${visitStart}&ndash;${visitEnd} (${duration})`;
955983
}
956-
return "&nbsp;";
984+
return `<strong>${dateString}</strong>`;
957985
});
958986
959987
const isDesktop = useMediaQuery("(min-width: 992px)");
@@ -1282,6 +1310,7 @@ const onScroll = (e: Event) => {
12821310
v-html="visitDurationString"
12831311
class="recording-header-time ms-2 ms-sm-2 text-secondary"
12841312
/>
1313+
<span class="recording-header-time ms-2 ms-sm-2 text-secondary" v-else v-html="visitDurationString"></span>
12851314
</div>
12861315
</div>
12871316
<div v-else>

0 commit comments

Comments
 (0)