mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
attemptLegacyImport should not break the entire request when it fails
This commit is contained in:
parent
140f9d566b
commit
c7bfed8bae
2 changed files with 14 additions and 8 deletions
|
@ -113,16 +113,21 @@ export const attemptLegacyImport = async (
|
||||||
config: Config,
|
config: Config,
|
||||||
id: string
|
id: string
|
||||||
): Promise<GuildData | null> => {
|
): Promise<GuildData | null> => {
|
||||||
const legacyGuildData = await fetchLegacyServer(config, id);
|
try {
|
||||||
if (!legacyGuildData) {
|
const legacyGuildData = await fetchLegacyServer(config, id);
|
||||||
// Means there is no legacy data.
|
if (!legacyGuildData) {
|
||||||
|
// Means there is no legacy data.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const transformed = transformLegacyGuild(legacyGuildData);
|
||||||
|
|
||||||
|
await config.kv.guildData.put(id, transformed);
|
||||||
|
return transformed;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('attemptLegacyImport errored:', e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformed = transformLegacyGuild(legacyGuildData);
|
|
||||||
|
|
||||||
await config.kv.guildData.put(id, transformed);
|
|
||||||
return transformed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getGuildMember = async (
|
export const getGuildMember = async (
|
||||||
|
|
|
@ -36,6 +36,7 @@ export const forbidden = () => json({ error: 'forbidden' }, { status: 403 });
|
||||||
export const notFound = () => json({ error: 'not found' }, { status: 404 });
|
export const notFound = () => json({ error: 'not found' }, { status: 404 });
|
||||||
export const serverError = (error: Error) => {
|
export const serverError = (error: Error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
console.trace();
|
||||||
return json({ error: 'internal server error' }, { status: 500 });
|
return json({ error: 'internal server error' }, { status: 500 });
|
||||||
};
|
};
|
||||||
export const notImplemented = () => json({ error: 'not implemented' }, { status: 501 });
|
export const notImplemented = () => json({ error: 'not implemented' }, { status: 501 });
|
||||||
|
|
Loading…
Add table
Reference in a new issue