feat: implement try/catch blocks on calls to fetch guild, channel, and messages
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful

This commit is contained in:
SauceyRed 2025-08-16 16:12:17 +02:00
parent 3e4e3e0ce8
commit 4e352fab70
Signed by: sauceyred
GPG key ID: 2BF92EB6D8A5CCA7
2 changed files with 25 additions and 8 deletions

View file

@ -56,10 +56,16 @@ const messagesType = ref<Record<string, "normal" | "grouped">>({});
const messageGroupingMaxDifference = useRuntimeConfig().public.messageGroupingMaxDifference
const timeFormat = getPreferredTimeFormat()
const messagesRes: MessageResponse[] | undefined = await fetchWithApi(
`${props.channelUrl}/messages`,
{ query: { "amount": props.amount ?? 100, "offset": props.offset ?? 0 } }
);
let messagesRes: MessageResponse[] | undefined;
try {
messagesRes = await fetchWithApi(
`${props.channelUrl}/messages`,
{ query: { "amount": props.amount ?? 100, "offset": props.offset ?? 0 } }
);
} catch (error) {
console.error("Failed to fetch messages:", error);
}
const firstMessageByUsers = ref<Record<string, MessageResponse | undefined>>({});
const previousMessage = ref<MessageResponse>();

View file

@ -16,8 +16,7 @@
</template>
<script lang="ts" setup>
import type { GuildMemberResponse } from '~/types/interfaces';
import type { ChannelResponse, GuildMemberResponse, GuildResponse } from '~/types/interfaces';
const route = useRoute();
const { fetchGuild, fetchChannel } = useApi()
@ -27,8 +26,20 @@ const guildId = route.params.serverId as string
const channelUrlPath = `channels/${channelId}`;
const guild = await fetchGuild(guildId)
const channel = await fetchChannel(channelId)
let guild: GuildResponse | undefined;
let channel: ChannelResponse | undefined;
try {
guild = await fetchGuild(guildId)
} catch (error) {
console.error("Failed to fetch guild:", error);
}
try {
channel = await fetchChannel(channelId)
} catch (error) {
console.error("Failed to fetch channel:", error);
}
const { fetchMeMember } = useApi();
const me = useState<GuildMemberResponse | undefined>("me");