-
Notifications
You must be signed in to change notification settings - Fork 95
Handling errors
Josh Hiles edited this page Dec 22, 2023
·
1 revision
If an exception is thrown in any of Scientist's internal helpers like Compare
, Enabled
, or Ignore
, the default behavior of Scientist is to re-throw that exception. Since this halts the experiment entirely, it's often a better idea to handle this error and continue so the experiment as a whole isn't canceled entirely:
Scientist.Science<int>("ExperimentCatch", experiment =>
{
experiment.Thrown((operation, exception) => InternalTracker.Track($"Science failure in ExperimentCatch: {operation}.", exception))
// ...
});
The operations that may be handled here are:
-
Operation.Compare
- an exception is raised in aCompare
block -
Operation.Enabled
- an exception is raised in theEnabled
block -
Operation.Ignore
- an exception is raised in anIgnore
block -
Operation.Publish
- an exception is raised while publishing results -
Operation.RunIf
- an exception is raised in aRunIf
block
- Publishing results
- Controlling comparison
- Adding context
- Expensive setup
- Keeping it clean
- Ignoring mismatches
- Enabling or disabling experiments
- Ramping up experiments
- Running candidates in parallel (asynchronous)
- Testing
- Handling errors
- Designing an experiment
- Finishing an experiment
Sometimes scientists just gotta do weird stuff. We understand.