Skip to content

Commit

Permalink
better inner support using cause
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed Aug 2, 2023
1 parent b497ea8 commit e378fd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions imports/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,8 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
}));

return { ...q, data: (q)?.data?.q0 };
} catch (error) {
const errorWrapper = new Error('There was an error with the Apollo query in DeepClient select method.') as any;
errorWrapper.innerError = error;
throw errorWrapper;
} catch (e) {
throw new Error(`DeepClient Select Error: ${e.message}`, { cause: e });
}
};

Expand All @@ -626,7 +624,7 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
} catch(e) {
const sqlError = e?.graphQLErrors?.[0]?.extensions?.internal?.error;
if (sqlError?.message) e.message = sqlError.message;
if (!this._silent(options)) throw e;
if (!this._silent(options)) throw new Error(`DeepClient Insert Error: ${e.message}`, { cause: e });
return { ...q, data: (q)?.data?.m0?.returning, error: e };
}
// @ts-ignore
Expand All @@ -648,7 +646,7 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
} catch(e) {
const sqlError = e?.graphQLErrors?.[0]?.extensions?.internal?.error;
if (sqlError?.message) e.message = sqlError.message;
if (!this._silent(options)) throw e;
if (!this._silent(options)) throw new Error(`DeepClient Update Error: ${e.message}`, { cause: e });
return { ...q, data: (q)?.data?.m0?.returning, error: e };
}
// @ts-ignore
Expand All @@ -672,7 +670,7 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
} catch(e) {
const sqlError = e?.graphQLErrors?.[0]?.extensions?.internal?.error;
if (sqlError?.message) e.message = sqlError.message;
if (!this._silent(options)) throw e;
if (!this._silent(options)) throw new Error(`DeepClient Delete Error: ${e.message}`, { cause: e });
return { ...q, data: (q)?.data?.m0?.returning, error: e };
}
return { ...q, data: (q)?.data?.m0?.returning };
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dom",
"es6",
"es7",
"ES2020"
"es2022.error"
],
"resolveJsonModule": true,
"esModuleInterop": true,
Expand Down

0 comments on commit e378fd1

Please sign in to comment.