Include an error code in every response
This commit is contained in:
11
errors.ts
11
errors.ts
@@ -1,6 +1,8 @@
|
|||||||
export enum ErrorCode {
|
export enum ErrorCode {
|
||||||
/** An error was not properly handled and assigned a more specific error code. */
|
/** No error occurred. This code should be included with all successful responses because the firmware expects some
|
||||||
UnexpectedError = 0,
|
* code to be present.
|
||||||
|
*/
|
||||||
|
NoError = 0,
|
||||||
|
|
||||||
/** The watering scale could not be calculated due to a problem with the weather information. */
|
/** The watering scale could not be calculated due to a problem with the weather information. */
|
||||||
BadWeatherData = 1,
|
BadWeatherData = 1,
|
||||||
@@ -46,7 +48,10 @@ export enum ErrorCode {
|
|||||||
/** The adjustment options could not be parsed. */
|
/** The adjustment options could not be parsed. */
|
||||||
MalformedAdjustmentOptions = 50,
|
MalformedAdjustmentOptions = 50,
|
||||||
/** A required adjustment option was not provided. */
|
/** A required adjustment option was not provided. */
|
||||||
MissingAdjustmentOption = 51
|
MissingAdjustmentOption = 51,
|
||||||
|
|
||||||
|
/** An error was not properly handled and assigned a more specific error code. */
|
||||||
|
UnexpectedError = 99
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An error with a numeric code that can be used to identify the type of error. */
|
/** An error with a numeric code that can be used to identify the type of error. */
|
||||||
|
|||||||
@@ -262,7 +262,8 @@ export const getWateringData = async function( req: express.Request, res: expres
|
|||||||
sunset: timeData.sunset,
|
sunset: timeData.sunset,
|
||||||
eip: ipToInt( remoteAddress ),
|
eip: ipToInt( remoteAddress ),
|
||||||
rawData: undefined,
|
rawData: undefined,
|
||||||
errMessage: undefined
|
errMessage: undefined,
|
||||||
|
errCode: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
let cachedScale: CachedScale;
|
let cachedScale: CachedScale;
|
||||||
@@ -293,6 +294,7 @@ export const getWateringData = async function( req: express.Request, res: expres
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.scale = adjustmentMethodResponse.scale;
|
data.scale = adjustmentMethodResponse.scale;
|
||||||
|
data.errCode = adjustmentMethodResponse.errCode || 0;
|
||||||
data.errMessage = adjustmentMethodResponse.errMessage;
|
data.errMessage = adjustmentMethodResponse.errMessage;
|
||||||
data.rd = adjustmentMethodResponse.rainDelay;
|
data.rd = adjustmentMethodResponse.rainDelay;
|
||||||
data.rawData = adjustmentMethodResponse.rawData;
|
data.rawData = adjustmentMethodResponse.rawData;
|
||||||
|
|||||||
Reference in New Issue
Block a user