feat(frontend): Navigatie voor leerpad geïmplementeerd.
This commit is contained in:
parent
3c3fddb7d0
commit
07340de2e3
13 changed files with 216 additions and 54 deletions
11
frontend/src/utils/response-assertions.ts
Normal file
11
frontend/src/utils/response-assertions.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
import {InvalidResponseException, NotFoundException} from "@/services/api-client/api-exceptions.ts";
|
||||
|
||||
export function single<T>(list: T[]): T {
|
||||
if (list.length === 1) {
|
||||
return list[0];
|
||||
} else if (list.length === 0) {
|
||||
throw new NotFoundException("Expected list with exactly one element, but got an empty list.");
|
||||
} else {
|
||||
throw new InvalidResponseException(`Expected list with exactly one element, but got one with ${list.length} elements.`);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue