Skip to content

Commit 6ef81cb

Browse files
authored
Add error handling to Table component (#6126)
1 parent 79426ad commit 6ef81cb

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

ui/packages/shared/profile/src/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const useVisibleNodes = ({
129129
renderedRangeRef.current = {
130130
minDepth: Infinity,
131131
maxDepth: -Infinity,
132-
table: table,
132+
table,
133133
};
134134
}
135135

ui/packages/shared/profile/src/ProfileView/components/DashboardItems/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export const getDashboardItem = ({
128128
case 'table':
129129
return topTableData != null ? (
130130
<Table
131+
error={topTableData.error}
131132
total={total}
132133
filtered={filtered}
133134
loading={topTableData.loading}

ui/packages/shared/profile/src/ProfileView/types/visualization.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14+
import {RpcError} from '@protobuf-ts/runtime-rpc';
15+
1416
import {FlamegraphArrow, QueryServiceClient, Source, TableArrow} from '@parca/client';
1517

1618
import {ProfileSource} from '../../ProfileSource';
@@ -20,7 +22,7 @@ export interface FlamegraphData {
2022
arrow?: FlamegraphArrow;
2123
total?: bigint;
2224
filtered?: bigint;
23-
error?: any;
25+
error: RpcError | null;
2426
metadataMappingFiles?: string[];
2527
metadataLoading: boolean;
2628
metadataLabels?: string[];
@@ -32,14 +34,14 @@ export interface TopTableData {
3234
arrow?: TableArrow;
3335
total?: bigint;
3436
filtered?: bigint;
35-
error?: any;
37+
error: RpcError | null;
3638
unit?: string;
3739
}
3840

3941
export interface SourceData {
4042
loading: boolean;
4143
data?: Source;
42-
error?: any;
44+
error: RpcError | null;
4345
}
4446

4547
export interface SandwichData {

ui/packages/shared/profile/src/Table/index.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import React, {useCallback, useEffect, useMemo, useRef} from 'react';
1515

16+
import {RpcError} from '@protobuf-ts/runtime-rpc';
1617
import {tableFromIPC} from 'apache-arrow';
1718
import {AnimatePresence, motion} from 'framer-motion';
1819
import {useContextMenu} from 'react-contexify';
@@ -59,6 +60,7 @@ export interface TableProps {
5960
isHalfScreen: boolean;
6061
unit?: string;
6162
metadataMappingFiles?: string[];
63+
error: RpcError | null;
6264
}
6365

6466
export const Table = React.memo(function Table({
@@ -70,6 +72,7 @@ export const Table = React.memo(function Table({
7072
isHalfScreen,
7173
unit,
7274
metadataMappingFiles,
75+
error,
7376
}: TableProps): React.JSX.Element {
7477
const currentColorProfile = useCurrentColorProfile();
7578
const [dashboardItems] = useURLState<string[]>('dashboard_items', {
@@ -220,6 +223,9 @@ export const Table = React.memo(function Table({
220223
</div>
221224
);
222225
}
226+
if (error != null) {
227+
return <div className="mx-auto text-center">Error: {error.message}</div>;
228+
}
223229

224230
if (rows.length === 0) {
225231
return <div className="mx-auto text-center">Profile has no samples</div>;

ui/packages/shared/profile/src/useSumBy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const useDraftSumBy = (
267267

268268
return {
269269
draftSumBy: draftSumBy ?? defaultSumBy ?? DEFAULT_EMPTY_SUM_BY,
270-
setDraftSumBy: setDraftSumBy,
270+
setDraftSumBy,
271271
isDraftSumByLoading: isLoading,
272272
};
273273
};

0 commit comments

Comments
 (0)