mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-15 19:47:57 +01:00
Improve error handling
This commit is contained in:
parent
1d2e441a63
commit
f48662bb6e
@ -47,9 +47,18 @@ export const fetchMapById = (id: number): MapLoadResult => {
|
|||||||
return client.fetchAllMaps();
|
return client.fetchAllMaps();
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = data?.find((m) => m.id == id);
|
let errorMsg: ErrorInfo = Object.keys(error).length !== 0 ? error : null;
|
||||||
const map = result || null;
|
let map: MapInfo;
|
||||||
return { isLoading: isLoading, error: error, map: map };
|
if (!isLoading) {
|
||||||
|
// Sanitize error structure ...
|
||||||
|
|
||||||
|
// If the map can not be loaded, create an error object.
|
||||||
|
map = data?.find((m) => m.id == id);
|
||||||
|
if (map === null && !errorMsg) {
|
||||||
|
errorMsg = { msg: `Map with id ${id} could not be found. Please, reflesh the page` }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { isLoading: isLoading, error: errorMsg, map: map };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchAccount = (): AccountInfo | undefined => {
|
export const fetchAccount = (): AccountInfo | undefined => {
|
||||||
|
Loading…
Reference in New Issue
Block a user