Skip to content

Show server errors on create in a very basic way - #345

Merged
david-crespo merged 4 commits into
mainfrom
server-errors
May 10, 2021
Merged

david-crespo merged 4 commits into
mainfrom
server-errors

Conversation

@david-crespo

Copy link
Copy Markdown
Collaborator

Closes #330

Pulling the string out of the server error is a bit of a hack and we'll want to polish it up later.

errors

@vercel

vercel Bot commented May 6, 2021 •

Copy link
Copy Markdown

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/oxidecomputer/console-ui-storybook/7RWYiS8n4FaXfvgnf5Drry3zxjSn
✅ Preview: https://console-ui-storybook-git-server-errors-oxidecomputer.vercel.app

@github-actions

github-actions Bot commented May 6, 2021

Copy link
Copy Markdown
Contributor

Comment thread libs/api/index.ts

const parseJsonAndRethrow = async (error: Response) =>
Promise.reject({ raw: error, data: await error.json() })

@david-crespo david-crespo May 6, 2021 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Everything else in this PR is pretty inconsequential because it's just last-mile display stuff, but this changes a widely used API so it's worth thinking about and revisiting. I was hoping to be able to leave the error value as a Response object, but you can only call .json() once on it (plus it returns a promise, so the calling code has to deal with async crap too). I want to be able to refer to the error JSON as many times as we need to in the calling code. So we just parse it out here once and for all.

@david-crespo
david-crespo temporarily deployed to Preview VM May 6, 2021 15:26 Inactive
@david-crespo
david-crespo temporarily deployed to Preview VM May 6, 2021 15:54 Inactive
@david-crespo
david-crespo temporarily deployed to Preview VM May 6, 2021 15:59 Inactive
@david-crespo
david-crespo temporarily deployed to Preview VM May 6, 2021 16:11 Inactive
@david-crespo
david-crespo temporarily deployed to Preview VM May 8, 2021 01:58 Inactive
@david-crespo
david-crespo merged commit e33e9d4 into main May 10, 2021
@david-crespo
david-crespo deleted the server-errors branch May 10, 2021 17:16

This branch was successfully deployed

1 active and 1 inactive deployments
Preview VM — ffd8a2fb Deployed May 8, 2021 by david-crespo
Preview — ffd8a2fb Deployed May 8, 2021 by vercel[bot]
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.

Display form-level server errors on project and instance create

1 participant