Skip to content

Commit

Permalink
error message improvements esp for new users
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Ramirez committed Nov 29, 2023
1 parent 859d636 commit cd6f415
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/modules/aifn/bigquery/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useBigQuery = (query: string, setBigQueryResult?: (results: any) =>
const setAccessToken = useAccessTokenStore((state) => state.setAccessToken);

const [loadingQuery, setLoadingQuery] = useState(false);
const [queryError, setQueryError] = useState(null);
const [queryError, setQueryError] = useState<null | string>(null);
const [loadingCost, setLoadingCost] = useState(false);
const [estimatedCost, setEstimatedCost] = useState<number | null>(null);
const [loadingSchema, setLoadingSchema] = useState(false);
Expand Down Expand Up @@ -187,9 +187,9 @@ export const useBigQuery = (query: string, setBigQueryResult?: (results: any) =>
const billableBytes = resp.result.totalBytesProcessed;
console.log(`Billable bytes: ${billableBytes}`);
setBigQueryResult && setBigQueryResult(resp.result);
setQueryError(null);
} catch (err: any) {
console.error('Query error during run', err);
console.log(err?.result?.error?.message || err?.result?.error?.status);
setQueryError(err?.result?.error?.message || err?.result?.error?.status);
}
setLoadingQuery(false);
Expand All @@ -214,9 +214,14 @@ export const useBigQuery = (query: string, setBigQueryResult?: (results: any) =>
console.log(`Billable bytes: ${billableBytes}`);
const cost = billableBytes * (6.25 / Math.pow(2, 40));
setEstimatedCost(cost);
setQueryError(null);
} catch (err: any) {
console.error('Query error during estimateCost', err);
setQueryError(err?.result?.error?.message || err?.result?.error?.status);
if (err?.status === 401) {
setQueryError('Please press the "Cost Estimate" button to log-in and evaluate this query');
} else {
setQueryError(err?.result?.error?.message || err?.result?.error?.status);
}
}
setLoadingCost(false);
};
Expand Down

0 comments on commit cd6f415

Please sign in to comment.