|
3 | 3 |
|
4 | 4 | #include "observation.h"
|
5 | 5 |
|
6 |
| -typedef struct { |
7 |
| - char buf[20]; |
8 |
| -} mustach_error_msg; |
9 |
| - |
10 |
| -static mustach_error_msg get_mustach_error_msg(int mustach_code){ |
| 6 | +static const char *mustach_strerror(int mustach_code){ |
11 | 7 | switch(mustach_code){
|
12 |
| - case MUSTACH_ERROR_SYSTEM : return (mustach_error_msg){"system error"}; |
13 |
| - case MUSTACH_ERROR_UNEXPECTED_END : return (mustach_error_msg){"unexpected end"}; |
14 |
| - case MUSTACH_ERROR_EMPTY_TAG : return (mustach_error_msg){"empty tag"}; |
15 |
| - case MUSTACH_ERROR_TAG_TOO_LONG : return (mustach_error_msg){"tag is too long"}; |
16 |
| - case MUSTACH_ERROR_BAD_SEPARATORS : return (mustach_error_msg){"bad separators"}; |
17 |
| - case MUSTACH_ERROR_TOO_DEEP : return (mustach_error_msg){"too deep"}; |
18 |
| - case MUSTACH_ERROR_CLOSING : return (mustach_error_msg){"closing"}; |
19 |
| - case MUSTACH_ERROR_BAD_UNESCAPE_TAG : return (mustach_error_msg){"bad unescape tag"}; |
20 |
| - case MUSTACH_ERROR_INVALID_ITF : return (mustach_error_msg){"invalid itf"}; |
21 |
| - case MUSTACH_ERROR_ITEM_NOT_FOUND : return (mustach_error_msg){"item not found"}; |
22 |
| - case MUSTACH_ERROR_PARTIAL_NOT_FOUND: return (mustach_error_msg){"partial not found"}; |
23 |
| - case MUSTACH_ERROR_UNDEFINED_TAG : return (mustach_error_msg){"undefined tag"}; |
24 |
| - default : return (mustach_error_msg){"unknown"}; |
| 8 | + case MUSTACH_ERROR_SYSTEM : return "system error"; |
| 9 | + case MUSTACH_ERROR_UNEXPECTED_END : return "unexpected end"; |
| 10 | + case MUSTACH_ERROR_EMPTY_TAG : return "empty tag"; |
| 11 | + case MUSTACH_ERROR_TAG_TOO_LONG : return "tag is too long"; |
| 12 | + case MUSTACH_ERROR_BAD_SEPARATORS : return "bad separators"; |
| 13 | + case MUSTACH_ERROR_TOO_DEEP : return "too deep"; |
| 14 | + case MUSTACH_ERROR_CLOSING : return "closing"; |
| 15 | + case MUSTACH_ERROR_BAD_UNESCAPE_TAG : return "bad unescape tag"; |
| 16 | + case MUSTACH_ERROR_INVALID_ITF : return "invalid itf"; |
| 17 | + case MUSTACH_ERROR_ITEM_NOT_FOUND : return "item not found"; |
| 18 | + case MUSTACH_ERROR_PARTIAL_NOT_FOUND: return "partial not found"; |
| 19 | + case MUSTACH_ERROR_UNDEFINED_TAG : return "undefined tag"; |
| 20 | + default : return "unknown"; |
25 | 21 | }
|
26 | 22 | }
|
27 | 23 |
|
@@ -56,7 +52,7 @@ void ereporter(plmustache_observation o){
|
56 | 52 | break;
|
57 | 53 | case ERROR_MUSTACH:
|
58 | 54 | ereport(ERROR,
|
59 |
| - errmsg("plmustache template processing failed: %s", get_mustach_error_msg(o.error_mustach_code).buf) |
| 55 | + errmsg("plmustache template processing failed: %s", mustach_strerror(o.error_mustach_code)) |
60 | 56 | );
|
61 | 57 | break;
|
62 | 58 | }
|
|
0 commit comments