Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move "invalid graph" warning to MapFieldInput #3689

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Sep 17, 2024

What?

Moves the "invalid graph" warning from a high level component, to the lower level MapFieldInput

Why?

I noticed when working on 11aa28a that I also needed to handle this error in the Page component. The actual component responsible for this dependency is the MapFieldInput, so it makes sense to do the error handling here once as opposed to remembering to do it in each parent which renders this component.

@DafyddLlyr DafyddLlyr force-pushed the dp/move-invalid-graph-error-to-MapInputField branch from d31b940 to a53711e Compare September 17, 2024 09:41
@DafyddLlyr DafyddLlyr changed the title fix: Move 'invalid graph' warning to MapFieldInput fix: Move "invalid graph" warning to MapFieldInput Sep 17, 2024
Copy link

github-actions bot commented Sep 17, 2024

Removed vultr server and associated DNS entries

@DafyddLlyr DafyddLlyr marked this pull request as ready for review September 17, 2024 10:04
@DafyddLlyr DafyddLlyr requested a review from a team September 17, 2024 10:04
Copy link
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

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

Working exactly as expected for List, just one question below about how much visibility we actually need here if mostly intended for editor feedback !

I think you've also missed removing the existing ErrorSummaryContainer from Map & Label, therefore still falling back to component first rather than field-level throw here ??

throw Error(
'Edit this flow so that this component is positioned after "FindProperty"; an address is required for schemas that include a "map" field.',
{ cause: "Invalid graph" },
);
Copy link
Member

Choose a reason for hiding this comment

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

nit: I'm not sure I'm sold on throwing an error here rather than rendering a component as before - do we want this noise coming through Airbrake?

Understand we can't easily render the whole component any longer from this shared position, but just wondering if there's a mechanism to exclude from Airbrake here etc?

Copy link
Contributor

@RODO94 RODO94 left a comment

Choose a reason for hiding this comment

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

Tested on the pizza and I still get the correct error messages. Although the format of the error is different to the error with the Map and Label component. I see this as separate to the purpose of this PR so happy to approve.

Should these be the same?

  • List Comp Error
Screenshot 2024-09-17 at 12 02 03
  • Map and Label Comp
Screenshot 2024-09-17 at 12 01 54

@DafyddLlyr DafyddLlyr force-pushed the dp/move-invalid-graph-error-to-MapInputField branch from edcb87b to b39f801 Compare September 17, 2024 16:20
@DafyddLlyr DafyddLlyr marked this pull request as draft September 17, 2024 16:21
@DafyddLlyr
Copy link
Contributor Author

@RODO94 @jessicamcinchak Thanks both for the feedback, please see recent commits which make the following changes -

  • Use the ErrorBoundary mechanism to throw and catch a new type of error - GraphError
  • This does not log to Airbrake
  • This maintains the same visual style as currently used by the invalid graph warnings
  • Ensures there's only a single place where the graph error component is defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's some basic tests here currently missing, I'll see if I can set this up in a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DafyddLlyr DafyddLlyr marked this pull request as ready for review September 18, 2024 06:59
function ErrorFallback(props: { error: Error }) {
logger.notify(props.error);
const ErrorFallback: React.FC<{ error: Error }> = ({ error }) => {
if (isGraphError(error)) return <GraphErrorComponent error={error} />;
Copy link
Member

Choose a reason for hiding this comment

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

This is a neat solution & I think we'll appreciate not having extra noise from these, thanks!

@DafyddLlyr DafyddLlyr merged commit 91275d7 into main Sep 18, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/move-invalid-graph-error-to-MapInputField branch September 18, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants