Throw errors instead of returning them

This commit is contained in:
Matthew Oslan
2019-09-02 11:32:38 -04:00
parent 2918527bcb
commit 1a1ecafcb0
3 changed files with 19 additions and 18 deletions

View File

@@ -2,7 +2,7 @@ import { AdjustmentMethod, AdjustmentMethodResponse, AdjustmentOptions } from ".
import { GeoCoordinates, PWS, ZimmermanWateringData } from "../../types";
import { validateValues } from "../weather";
import { WeatherProvider } from "../weatherProviders/WeatherProvider";
import { ErrorCode } from "../../errors";
import { CodedError, ErrorCode } from "../../errors";
/**
@@ -39,12 +39,7 @@ async function calculateZimmermanWateringScale(
// Check to make sure valid data exists for all factors
if ( !validateValues( [ "temp", "humidity", "precip" ], wateringData ) ) {
// Default to a scale of 100% if fields are missing.
return {
scale: 100,
rawData: rawData,
errCode: ErrorCode.MissingWeatherField,
wateringData: wateringData
};
throw new CodedError( ErrorCode.MissingWeatherField );
}
let humidityBase = 30, tempBase = 70, precipBase = 0;