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 }; const signalListeners = { mousemove: handleHover, mouseout: handleOut };
//TODO: This custom error handling is a bit hacky and should be improved. //TODO: This custom error handling is a bit hacky and should be improved.
let mouseItem: result<SqValue, SqError> = !!mouseOverlay let showChart: JSX.Element | null = null;
? fn.call([mouseOverlay]) if (!isNaN(mouseOverlay)) {
: { let mouseItem = fn.call([mouseOverlay]);
tag: "Error",
value: SqError.createOtherError( showChart =
"Hover x-coordinate returned NaN. Expected a number." mouseItem.tag === "Ok" &&
), mouseItem.value.tag === SqValueTag.Distribution ? (
}; <DistributionChart
let showChart = plot={defaultPlot(mouseItem.value.value)}
mouseItem.tag === "Ok" && environment={environment}
mouseItem.value.tag === SqValueTag.Distribution ? ( width={400}
<DistributionChart height={50}
plot={defaultPlot(mouseItem.value.value)} {...distributionPlotSettings}
environment={environment} />
width={400} ) : null;
height={50} }
{...distributionPlotSettings}
/>
) : null;
let getPercentilesMemoized = React.useMemo( let getPercentilesMemoized = React.useMemo(
() => getPercentiles({ chartSettings, fn, environment }), () => 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) let createOtherError = (v: string) => Reducer_ErrorValue.REOther(v)
@genType @genType
let getErrorSource = (err: reducerErrorValueWithSource) => err.sourceId let getSource = (err: reducerErrorValueWithSource) => err.sourceId