Skip to content

[data grid] Introduce throwMissingRowError utility for consistent error handling#22325

Open
sai6855 wants to merge 2 commits intomui:masterfrom
sai6855:row-id
Open

[data grid] Introduce throwMissingRowError utility for consistent error handling#22325
sai6855 wants to merge 2 commits intomui:masterfrom
sai6855:row-id

Conversation

@sai6855
Copy link
Copy Markdown
Member

@sai6855 sai6855 commented May 5, 2026

Consolidate the duplicated throw new Error(`MUI X: No row with id #${id} found`) pattern into a single
throwMissingRowError(id) helper exported from gridRowsUtils.ts. Replaces 10 call sites (8 bare throw + 2 file-private

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 5, 2026

Deploy preview

⚠️ Failed to generate deploy preview.

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid ▼-146B(-0.04%) ▼-36B(-0.03%)
@mui/x-data-grid-pro ▼-146B(-0.03%) ▼-24B(-0.02%)
@mui/x-data-grid-premium ▼-215B(-0.03%) ▼-42B(-0.02%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@sai6855 sai6855 added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: data grid Changes related to the data grid. labels May 5, 2026
@sai6855 sai6855 requested review from arminmeh and michelengelen May 5, 2026 12:57
@sai6855 sai6855 marked this pull request as ready for review May 5, 2026 12:58
Copilot AI review requested due to automatic review settings May 5, 2026 12:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR centralizes the “missing row” error throw logic into a shared throwMissingRowError(id) utility (exported from gridRowsUtils.ts) and replaces multiple duplicated throw new Error(...) call sites across the Data Grid community and premium codepaths.

Changes:

  • Add throwMissingRowError(id: GridRowId): never to gridRowsUtils.ts and export it via @mui/x-data-grid/internals.
  • Replace several inline missing-row throw new Error(...) statements with throwMissingRowError(...) in row/params hooks.
  • Update premium features to reuse the centralized helper via internals exports.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/x-data-grid/src/internals/index.ts Re-exports throwMissingRowError through the community internals barrel.
packages/x-data-grid/src/hooks/features/rows/useGridRowsOverridableMethods.ts Uses throwMissingRowError for missing source/target nodes in row reordering.
packages/x-data-grid/src/hooks/features/rows/useGridRows.ts Uses throwMissingRowError when toggling group expansion for a non-existent node.
packages/x-data-grid/src/hooks/features/rows/useGridParamsOverridableMethods.ts Uses throwMissingRowError for getCellValue when the row is missing.
packages/x-data-grid/src/hooks/features/rows/useGridParamsApi.ts Uses throwMissingRowError and removes the local MissingRowIdError class.
packages/x-data-grid/src/hooks/features/rows/gridRowsUtils.ts Introduces the throwMissingRowError helper.
packages/x-data-grid-premium/src/hooks/features/rows/useGridRowsOverridableMethods.ts Switches to throwMissingRowError for missing nodes during row reorder operations.
packages/x-data-grid-premium/src/hooks/features/export/serializer/excelSerializer.ts Uses throwMissingRowError when row/rowNode are missing during Excel serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/x-data-grid/src/hooks/features/rows/gridRowsUtils.ts Outdated
Comment on lines +17 to 19
import { throwMissingRowError } from './gridRowsUtils';
import type { GridConfiguration } from '../../../models/configuration/gridConfiguration';

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: sai chand <60743144+sai6855@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: data grid Changes related to the data grid. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants