From c0713b16c24f63c543b80781d2ae40d833203777 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Mon, 5 Sep 2022 13:03:56 +0200 Subject: [PATCH] tweak: Add better error messages for common use case I.e., the case of integrating a function which doesn't return a number but a distribution --- .../src/rescript/FunctionRegistry/Library/FR_Danger.res | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res index ec992178..67910789 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res @@ -161,7 +161,10 @@ module Internals = { } resultWithOuterPoints } - | false => Error("Integration error 3 in Danger.integrate") + | false => + Error( + "Integration error 3 in Danger.integrate. It's possible that your function doesn't return a number, try definining auxiliaryFunction(x) = mean(yourFunction(x)) and integrate auxiliaryFunction instead", + ) } result } @@ -286,12 +289,10 @@ let library = [ numIntegrationPoints, env, reducer, - )->E.R2.errMap(_ => - "Integration error 5 in Danger.integrate. Something went wrong along the way" ) | _ => Error( - "Integration error 6 in Danger.integrate. Remember that inputs are (function, number (min), number (max), number(increment))", + "Integration error 5 in Danger.integrate. Remember that inputs are (function, number (min), number (max), number(increment))", ) } result