Skip to content

Commit

Permalink
better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Jul 3, 2023
1 parent 23522d4 commit 49bd7c7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/LoadError.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ReactNode, useMemo } from "react";
import { LoadResultError } from "../data/useLoadEffect.ts";
import css from "./Loading.module.css";

export type LoadErrorProps = {
operation: string;
Expand All @@ -19,10 +20,13 @@ function LoadError({ operation, result: { error, retry } }: LoadErrorProps) {
const formattedError = useMemo(() => formatError(error), [error]);

return (
<div>
<div>{operation} failed</div>
<div>{formattedError}</div>
<button onClick={() => retry()}>Retry</button>
<div className={css.container}>
<div className={css.indicator + " " + css.errorIndicator} />
<div className={css.message}>
<div className={css.errorMessage}>{operation} failed</div>
<div className={css.errorDetails}>{formattedError}</div>
<button onClick={() => retry()}>Retry</button>
</div>
</div>
);
}
Expand Down
22 changes: 22 additions & 0 deletions src/components/Loading.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
background-size: contain;
image-rendering: smooth;
position: relative;

filter: drop-shadow(11px 11px 4px rgba(0, 0, 0, 0.5));
}

.indicator::after {
Expand All @@ -35,6 +37,11 @@
animation-iteration-count: infinite;
}

.errorIndicator.indicator::after {
animation: unset;
background-color: crimson;
}

@keyframes controller-lights {
100%, 0% {
background-color: #457BFA;
Expand Down Expand Up @@ -77,4 +84,19 @@
.message {
margin-top: 1em;
color: #666666;
max-width: 800px;
text-align: center;
border-radius: 15px;
background-color: rgb(0, 0, 0, 0.5);
padding: 20px;
}

.errorMessage {
color: crimson;
font-weight: bold;
margin-bottom: 0.5em;
}

.errorDetails {
margin-bottom: 0.5em;
}

0 comments on commit 49bd7c7

Please sign in to comment.