Remove errMessage

This commit is contained in:
Matthew Oslan
2019-09-01 15:05:41 -04:00
parent f8d3c64a33
commit 2918527bcb
9 changed files with 29 additions and 42 deletions

View File

@@ -29,11 +29,11 @@ export default class DarkSkyWeatherProvider extends WeatherProvider {
yesterdayData = await httpJSONRequest( yesterdayUrl );
} catch ( err ) {
console.error( "Error retrieving weather information from Dark Sky:", err );
throw new CodedError( ErrorCode.WeatherApiError, "An error occurred while retrieving weather information from Dark Sky." );
throw new CodedError( ErrorCode.WeatherApiError );
}
if ( !yesterdayData.hourly || !yesterdayData.hourly.data ) {
throw new CodedError( ErrorCode.MissingWeatherField, "Necessary field(s) were missing from weather information returned by Dark Sky." );
throw new CodedError( ErrorCode.MissingWeatherField );
}
const samples = [
@@ -42,7 +42,7 @@ export default class DarkSkyWeatherProvider extends WeatherProvider {
// Fail if not enough data is available.
if ( samples.length !== 24 ) {
throw new CodedError( ErrorCode.InsufficientWeatherData, "Insufficient data was returned by Dark Sky." );
throw new CodedError( ErrorCode.InsufficientWeatherData );
}
const totals = { temp: 0, humidity: 0, precip: 0 };
@@ -123,7 +123,7 @@ export default class DarkSkyWeatherProvider extends WeatherProvider {
try {
historicData = await httpJSONRequest( historicUrl );
} catch (err) {
throw new CodedError( ErrorCode.WeatherApiError, "An error occurred while retrieving weather information from Dark Sky." );
throw new CodedError( ErrorCode.WeatherApiError );
}
const cloudCoverInfo: CloudCoverInfo[] = historicData.hourly.data.map( ( hour ): CloudCoverInfo => {

View File

@@ -26,12 +26,12 @@ export default class OWMWeatherProvider extends WeatherProvider {
forecast = await httpJSONRequest( forecastUrl );
} catch ( err ) {
console.error( "Error retrieving weather information from OWM:", err );
throw new CodedError( ErrorCode.WeatherApiError, "An error occurred while retrieving weather information from OWM." );
throw new CodedError( ErrorCode.WeatherApiError );
}
// Indicate watering data could not be retrieved if the forecast data is incomplete.
if ( !forecast || !forecast.list ) {
throw new CodedError( ErrorCode.MissingWeatherField, "Necessary field(s) were missing from weather information returned by OWM." );
throw new CodedError( ErrorCode.MissingWeatherField );
}
let totalTemp = 0,
@@ -112,12 +112,12 @@ export default class OWMWeatherProvider extends WeatherProvider {
forecast = await httpJSONRequest( forecastUrl );
} catch (err) {
console.error( "Error retrieving ETo information from OWM:", err );
throw new CodedError( ErrorCode.WeatherApiError, "An error occurred while retrieving ETo information from OWM." );
throw new CodedError( ErrorCode.WeatherApiError );
}
// Indicate ETo data could not be retrieved if the forecast data is incomplete.
if ( !forecast || !forecast.list || forecast.list.length < 8 ) {
throw new CodedError( ErrorCode.InsufficientWeatherData, "Insufficient data available from OWM." );
throw new CodedError( ErrorCode.InsufficientWeatherData );
}
// Take a sample over 24 hours.

View File

@@ -7,7 +7,7 @@ export default class WUnderground extends WeatherProvider {
async getWateringData( coordinates: GeoCoordinates, pws?: PWS ): Promise< ZimmermanWateringData > {
if ( !pws ) {
throw new CodedError( ErrorCode.NoPwsProvided, "WUnderground WeatherProvider requires a PWS to be specified." );
throw new CodedError( ErrorCode.NoPwsProvided );
}
const url = `https://api.weather.com/v2/pws/observations/hourly/7day?stationId=${ pws.id }&format=json&units=e&apiKey=${ pws.apiKey }`;
@@ -16,7 +16,7 @@ export default class WUnderground extends WeatherProvider {
data = await httpJSONRequest( url );
} catch ( err ) {
console.error( "Error retrieving weather information from WUnderground:", err );
throw new CodedError( ErrorCode.WeatherApiError, "An error occurred while retrieving weather information from WUnderground." );
throw new CodedError( ErrorCode.WeatherApiError );
}
// Take the 24 most recent observations.
@@ -24,7 +24,7 @@ export default class WUnderground extends WeatherProvider {
// Fail if not enough data is available.
if ( samples.length !== 24 ) {
throw new CodedError( ErrorCode.InsufficientWeatherData, "Insufficient data was returned by WUnderground." );
throw new CodedError( ErrorCode.InsufficientWeatherData );
}
const totals = { temp: 0, humidity: 0, precip: 0 };

View File

@@ -13,7 +13,7 @@ export class WeatherProvider {
* does not support this method).
*/
getWateringData( coordinates: GeoCoordinates, pws?: PWS ): Promise< ZimmermanWateringData > {
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod, "Selected WeatherProvider does not support getWateringData" );
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod );
}
/**
@@ -34,7 +34,7 @@ export class WeatherProvider {
* CodedError if an error occurs while retrieving the EToData (or the WeatherProvider does not support this method).
*/
getEToData( coordinates: GeoCoordinates ): Promise< EToData > {
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod, "Selected WeatherProvider does not support getEToData" );
throw new CodedError( ErrorCode.UnsupportedAdjustmentMethod );
};
/**