Skip to content

Commit

Permalink
fix: Handle unhandled errors in dev server UI (#416)
Browse files Browse the repository at this point in the history
This handles errors by logging them to the console in places where we had TODO
comments for error handling.
  • Loading branch information
mike-zorn authored Aug 29, 2024
1 parent 67cc93a commit afe5281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/dev_server/ui/dist/index.html

Large diffs are not rendered by default.

12 changes: 3 additions & 9 deletions internal/dev_server/ui/src/Flags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Flags({ selectedProject, flags, setFlags }: FlagProps) {
})
.then(async (res) => {
if (!res.ok) {
return; // todo
throw new Error(`got ${res.status} ${res.statusText}. ${await res.text()}`)
}

const updatedOverrides = {
Expand All @@ -58,9 +58,7 @@ function Flags({ selectedProject, flags, setFlags }: FlagProps) {

setOverrides(updatedOverrides);
})
.catch((_e) => {
// todo
});
.catch( console.error.bind(console, "unable to update override"));
};

const removeOverride = (flagKey: string, updateState: boolean = true) => {
Expand All @@ -71,8 +69,6 @@ function Flags({ selectedProject, flags, setFlags }: FlagProps) {
},
)
.then((res) => {
// todo: clean this up.
//
// In the remove-all-override case, we need to fan out and make the
// request for every override, so we don't want to be interleaving
// local state updates. Expect the consumer to update the local state
Expand All @@ -87,9 +83,7 @@ function Flags({ selectedProject, flags, setFlags }: FlagProps) {
setOnlyShowOverrides(false);
}
})
.catch((_e) => {
// todo
});
.catch( console.error.bind("unable to remove override") );
};

const fetchFlags = async () => {
Expand Down

0 comments on commit afe5281

Please sign in to comment.