Fix some build errors about error values

This commit is contained in:
Sam Nolan 2022-09-22 17:29:02 +10:00
parent e2e30641b3
commit eb86d12d63
2 changed files with 17 additions and 20 deletions

View File

@ -172,25 +172,22 @@ export const FunctionChart1Dist: React.FC<FunctionChart1DistProps> = ({
const signalListeners = { mousemove: handleHover, mouseout: handleOut };
//TODO: This custom error handling is a bit hacky and should be improved.
let mouseItem: result<SqValue, SqError> = !!mouseOverlay
? fn.call([mouseOverlay])
: {
tag: "Error",
value: SqError.createOtherError(
"Hover x-coordinate returned NaN. Expected a number."
),
};
let showChart =
mouseItem.tag === "Ok" &&
mouseItem.value.tag === SqValueTag.Distribution ? (
<DistributionChart
plot={defaultPlot(mouseItem.value.value)}
environment={environment}
width={400}
height={50}
{...distributionPlotSettings}
/>
) : null;
let showChart: JSX.Element | null = null;
if (!isNaN(mouseOverlay)) {
let mouseItem = fn.call([mouseOverlay]);
showChart =
mouseItem.tag === "Ok" &&
mouseItem.value.tag === SqValueTag.Distribution ? (
<DistributionChart
plot={defaultPlot(mouseItem.value.value)}
environment={environment}
width={400}
height={50}
{...distributionPlotSettings}
/>
) : null;
}
let getPercentilesMemoized = React.useMemo(
() => getPercentiles({ chartSettings, fn, environment }),

View File

@ -19,4 +19,4 @@ let createTodoError = (v: string) => Reducer_ErrorValue.RETodo(v)
let createOtherError = (v: string) => Reducer_ErrorValue.REOther(v)
@genType
let getErrorSource = (err: reducerErrorValueWithSource) => err.sourceId
let getSource = (err: reducerErrorValueWithSource) => err.sourceId