Commit 85cb7994 authored by David Björkheim's avatar David Björkheim
Browse files

DEICH-5558 Deichman.no: Add better error handling

parent 9a34bd7e
......@@ -101,7 +101,7 @@ export default function PublicationCard({
data-cy="publication-card-year"
>
<span className="publication-card__term">Utgitt</span>{" "}
{publicationYear}
<span>{publicationYear}</span>
</div>
)}
{mediaType === AUDIO_BOOK && reader && (
......
......@@ -50,7 +50,7 @@ export default function PublicationsAccordionContainer({ publication }) {
</Block>
)}
{!isLoading && publications.length === 0 && (
<Block top={5}> Her fantes det ingen utgaver å vise</Block>
<Block top={5}>Her fantes det ingen utgaver å vise</Block>
)}
</>
</Accordion>
......@@ -72,6 +72,12 @@ function LoadDataTrigger(props) {
.map(p => p.recordId)
.join(",")}`
);
if (res.status != 200) {
const body = await res.text();
throw new Error(
`Bad response from server - status "${res.status}" - ${body}`
);
}
const newCopies = await res.json();
!controls.canceled &&
setCopies({
......
......@@ -236,10 +236,17 @@ async function getCopies(publication) {
.map(p => p.recordId)
.join(",")}`
);
if (res.status != 200) {
const body = await res.text();
throw new Error(
`Bad response from server - status "${res.status}" - ${body}`
);
}
return res.json();
} catch (err) {
console.error(err);
}
return [];
}
export function notReservableReason(publication, copies) {
const items = copies[publication.recordId]?.items || [];
......
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