Gist card: handle not found error (#3100)

This commit is contained in:
Alexandr Garbuzov
2023-08-20 09:58:16 +02:00
committed by GitHub
parent c3c5a0dd32
commit 93733caaa6
2 changed files with 19 additions and 0 deletions
+1
View File
@@ -60,6 +60,7 @@ const fetchGist = async (id) => {
if (!id) throw new MissingParamError(["id"], "/api/gist?id=GIST_ID");
const res = await retryer(fetcher, { gistName: id });
if (res.data.errors) throw new Error(res.data.errors[0].message);
if (!res.data.data.viewer.gist) throw new Error("Gist not found");
const data = res.data.data.viewer.gist;
return {
name: data.files[Object.keys(data.files)[0]].name,