Add error codes to watering data errors
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { GeoCoordinates, PWS, WeatherData, ZimmermanWateringData } from "../../types";
|
||||
import { EToData } from "../adjustmentMethods/EToAdjustmentMethod";
|
||||
import { CodedError, ErrorCode } from "../../errors";
|
||||
|
||||
export class WeatherProvider {
|
||||
/**
|
||||
@@ -8,11 +9,11 @@ export class WeatherProvider {
|
||||
* @param pws The PWS to retrieve the weather from, or undefined if a PWS should not be used. If the implementation
|
||||
* of this method does not have PWS support, this parameter may be ignored and coordinates may be used instead.
|
||||
* @return A Promise that will be resolved with the ZimmermanWateringData if it is successfully retrieved,
|
||||
* or rejected with an error message if an error occurs while retrieving the ZimmermanWateringData or the WeatherProvider
|
||||
* does not support this method.
|
||||
* or rejected with a CodedError if an error occurs while retrieving the ZimmermanWateringData (or the WeatherProvider
|
||||
* does not support this method).
|
||||
*/
|
||||
getWateringData( coordinates: GeoCoordinates, pws?: PWS ): Promise< ZimmermanWateringData > {
|
||||
throw "Selected WeatherProvider does not support getWateringData";
|
||||
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod, "Selected WeatherProvider does not support getWateringData" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,12 +30,11 @@ export class WeatherProvider {
|
||||
/**
|
||||
* Retrieves the data necessary for calculating potential ETo.
|
||||
* @param coordinates The coordinates to retrieve the data for.
|
||||
* @return A Promise that will be resolved with the EToData if it is successfully retrieved,
|
||||
* or rejected with an error message if an error occurs while retrieving the EToData or the WeatherProvider does
|
||||
* not support this method.
|
||||
* @return A Promise that will be resolved with the EToData if it is successfully retrieved, or rejected with a
|
||||
* CodedError if an error occurs while retrieving the EToData (or the WeatherProvider does not support this method).
|
||||
*/
|
||||
getEToData( coordinates: GeoCoordinates ): Promise< EToData > {
|
||||
throw "Selected WeatherProvider does not support getEToData";
|
||||
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod, "Selected WeatherProvider does not support getEToData" );
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user