~xenrox/10man-ts3

0c84f94f319fb5bcc6e2768d783eaa878aec2113 — Thorben Günther 2 years ago c0cb2f4
Improve error handling

App will no longer crash, if the error response cannot be parsed (e.g.
when API is down).
1 files changed, 5 insertions(+), 1 deletions(-)

M app.ts
M app.ts => app.ts +5 -1
@@ 122,7 122,11 @@ async function message_id(teamspeakID: string, msg: string) {
}

function get_error(e: unknown): string {
    return JSON.parse(JSON.stringify(e)).response.errors[0].message;
    try {
        return JSON.parse(JSON.stringify(e)).response.errors[0].message;
    } catch {
        return e as string;
    }
}

async function request(query: string, variables?: Variables): Promise<any> {