Skip to content

Commit

Permalink
Fix #46 - Add GitHub GraphQL API error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshino committed Oct 1, 2023
1 parent 5d14f6b commit b77aa8f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/services/backends/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createFileList, parseAssetFiles, parseEntryFiles } from '$lib/services/
import { user } from '$lib/services/user';
import { getBase64 } from '$lib/services/utils/files';
import IndexedDB from '$lib/services/utils/indexeddb';
import { isObject } from '$lib/services/utils/misc';

const label = 'GitHub';
/**
Expand Down Expand Up @@ -53,7 +54,13 @@ const fetchAPI = async (
let message;

try {
({ message } = (await response.json()) || {});
const result = await response.json();

if (isObject(result)) {
message =
result.message ?? // REST
result.errors?.[0]?.message; // GraphQL
}
} catch {
//
}
Expand Down

0 comments on commit b77aa8f

Please sign in to comment.