|
| 1 | +#ifndef ENTSERVICES_ERRORCODES_H |
| 2 | +#define ENTSERVICES_ERRORCODES_H |
| 3 | +#pragma once |
| 4 | +#include <stdio.h> |
| 5 | + |
| 6 | +// 1. A list of Plugin specific errors. |
| 7 | +// As per https://www.jsonrpc.org/specification#error_object, implementation defined error range is -32000 to -32099 |
| 8 | +// So, we have room for only 100 errors across all entertainment services in RDK. |
| 9 | +// Please define error code in reusable form (or generic form), wherever possible. |
| 10 | +// Always consult Thunder Framework defined errors before defining a new error. |
| 11 | +#define ERROR_LIST \ |
| 12 | + X(ERROR_INVALID_DEVICENAME, "Invalid device name") \ |
| 13 | + X(ERROR_INVALID_MOUNTPOINT, "Invalid mount path") \ |
| 14 | + X(ERROR_FIRMWAREUPDATE_INPROGRESS, "Firmware update already in progress") \ |
| 15 | + X(ERROR_FIRMWAREUPDATE_UPTODATE, "Firmware is already upto date") \ |
| 16 | + X(ERROR_FILE_IO, "File Read or Write error") \ |
| 17 | + |
| 18 | + |
| 19 | +/******** PLEASE DO NOT MODIFY ANYTHING BELOW THIS **********/ |
| 20 | +// 2. Define the 'X' macro to generate the enum. |
| 21 | +#define X(name, string) name, |
| 22 | +enum ErrorCodeEnum{ |
| 23 | + // Start the first error code at 1000 |
| 24 | + ERROR_BASE = 1000, |
| 25 | + ERROR_LIST |
| 26 | + MAX_ERROR_CODE |
| 27 | +}; |
| 28 | +// Undefine 'X' to avoid conflicts. |
| 29 | +#undef X |
| 30 | + |
| 31 | +// 3. Define the 'X' macro to generate the string array. |
| 32 | +#define X(name, string) string, |
| 33 | +const char* const error_strings[] = { |
| 34 | + "Error base", |
| 35 | + ERROR_LIST |
| 36 | + "Unknown error code" |
| 37 | +}; |
| 38 | + |
| 39 | +//4.Check if Error code is within the entservices error code range. |
| 40 | +#define IS_ENTSERVICES_ERRORCODE(errorcode) \ |
| 41 | + ((errorcode) >= ERROR_BASE && \ |
| 42 | + (errorcode) < MAX_ERROR_CODE) |
| 43 | + |
| 44 | + |
| 45 | +//5.Fetch Error strings |
| 46 | +#define ERROR_MESSAGE(errorcode) (error_strings[(errorcode) - ERROR_BASE]) |
| 47 | + |
| 48 | +#endif //ENTSERVICES_ERRORCODES_H |
0 commit comments