mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 17:49:09 +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,
|
||||
id: string
|
||||
): Promise<GuildData | null> => {
|
||||
const legacyGuildData = await fetchLegacyServer(config, id);
|
||||
if (!legacyGuildData) {
|
||||
// Means there is no legacy data.
|
||||
try {
|
||||
const legacyGuildData = await fetchLegacyServer(config, id);
|
||||
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;
|
||||
}
|
||||
|
||||
const transformed = transformLegacyGuild(legacyGuildData);
|
||||
|
||||
await config.kv.guildData.put(id, transformed);
|
||||
return transformed;
|
||||
};
|
||||
|
||||
export const getGuildMember = async (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue