Introduction
This document describes how to construct Error codes for all operations
Background
Jira Issues
https://project-sunbird.atlassian.net/browse/SB-21578
Examples Of Error code
PFT_CCRT10 >> PBK_CCRT10 >> DMW_CCRT10 >> NBB_CCRT10 TraceId: 1234 Error happened at NodeBB end. NBB_CCRT10 << NBB_CCRT10 << NBB_CCRT10 << NBB_CCRT10 ===> Servies: Discussion Middleware service -> DMW NodeBB Sercie -> NBB ===> Operations: Category create - CCRT Topic create - TCRT Group create - GCRT Usr create - UCRT ===> ERROR CODES: 01 - Category creation failed because of reason 1? 02 - Category create failed because of reason 2? 03 - Category update failed because of reason 1? 04 - Category update failed because of reason 2? ... DMW_CCRT01 NBB_GCRT{error_code}
Problem Statement:
How to assign specific error code to api?
Solution:
API | Unique Operation Name | Operation Name | Error Number | Error Description | Error Code | API errors- Revised | User Interface error |
---|---|---|---|---|---|---|---|
FORUM API's | |||||||
/forum/v2/read | FRED | DMW_FRED | 01 | Forum read failed because of nodebb-plugin-create-forum plugin not enabled. | DMW_FRED01 | The nodebb plug-in or the API is not available. Contact your system administrator to enable it. | Could not read Forum. Try again later. |
/forum/v2/read | FRED | DMW_FRED | 02 | Forum read failed because of request payload issue | DMW_FRED02 | Mandatory fields are missing in the request. Enter the required values and resend the request. | Could not read Forum. Try again later. |
/forum/v2/read | FRED | DMW_FRED | 03 | Forum read failed | DMW_FRED03 | Forum read failed due to internal server error or database issues. Try again later. | Could not read Forum. Try again later. |
/forum/v2/create | FCRT | DMW_FCRT | 04 | Forum create failed because nodebb-plugin-create-forum not enabled. | DMW_FCRT04 | Forum creation failed as the nodebb plug-in or the API is not available. Contact your system administrator to enable it. | Could not create Forum. Contact your system administrator. |
/forum/v2/create | DMW_FCRT | 05 | Forum create failed because of request payload issue. | DMW_FCRT05 | Forum creation failed, mandatory fields are missing in the request. Enter the required values and resend the request. | Could not create forum, re-enter the values and try again. | |
/forum/v2/create | DMW_FCRT | 06 | Forum create failed | DMW_FCRT06 | Forum creation failed due to internal server error or database issues. Try again later. | Could not create forum, try again later. | |
/forum/v2/remove | FREM | DMW_FREM | 07 | Forum remove failed because nodebb-plugin-create-forum not enabled. | DMW_FREM07 | Removing forum failed, the nodebb plug-in or the API is not available. Contact your system administrator to enable it. | Could not remove forum. Contact your system administrator |
/forum/v2/remove | DMW_FREM | 08 | Forum remove failed | DMW_FREM08 | Removing forum failed as mandatory fields are missing in the request. Enter the required values and resend the request. | Could not remove forum. Try again later. | |
/forum/v2/remove | DMW_FREM | 09 | Forum remove failed because of request pay is incorrect | DMW_FREM09 | Removing Forum failed due to internal server error or database issues. Try again later. | Could not remove forum. Try again later. | |
Tags API | |||||||
/tags | TRED | DMW_TRED | 01 | Tags read failed | DMW_TRED01 | Reading tags failed due to internal server error or database issues. Try again later. | Could not read tags. Try again later |
/tags/list | TLST | DMW_TLST | 02 | Tags list read failed | DMW_TLST02 | Reading tags failed due to internal server error or database issues. Try again later. | Could not read tags. Try again later |
/tags/:tag | TRDIS | DMW_TRDIS | 03 | Tag details read failed | DMW_TRDIS03 | Reading tags failed due to internal server error or database issues. Try again later. | Could not read tags. Try again later. |
/tags/list | TLSL | DMW_TLST | 04 | Tag list failed because nodebb-plugin-create-forum not enabled. | DMW_TLST04 | Tag list failed as, the nodebb plug-in or the API is not available. Contact your system administrator to enable it. | Could not read tags. Try again later. |
/tags/list | TSLS | DMW_TLST | 05 | Tag list failed because of request payload is incorrect | DMW_TLST05 | Tag list failed as mandatory fields are missing in the request. Enter the required values and resend the request. | Could not read tags. Try again later. |
USER DETAILS API's | |||||||
/user/:userslug | URED | DMW_URED | 01 | User details read failed | DMW_URED01 | Failed to read user details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read user details. Try again later. |
/user/:userslug | DMW_URED | 02 | Users details read failed because of user not exists | DMW_URED02 | Failed to read user details, user does not exists. Contact your system administrator. | User does not exists. Contact your system administrator. | |
/user/:userslug/upvoted | UUVR | DMW_URED | 03 | User up vote post details read failed | DMW_UUVR03 | Failed to read user up-vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read up vote post. Try again later. |
/user/:userslug/upvoted | DMW_URED | 04 | User up vote post details read failed because of user not exists | DMW_UUVR04 | Failed to read user up-vote post details, user does not exist. Contact your system administrator. | Could not read up vote post as user does not exists. Contact your system administrator. | |
/user/:userslug/downvoted | UDVR | DMW_URED | 05 | User down vote post details read failed | DMW_UDVR05 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read down vote post. Try again later. |
/user/:userslug/downvoted | DMW_URED | 06 | User down vote post details read failed because of user not exists. | DMW_UDVR06 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not read down vote post as user does not exists. Contact your system administrator. | |
/user/:userslug/bookmarks | UBMR | DMW_URED | 07 | User saved post details read failed | DMW_UBMR07 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read saved post. Try again later. |
/user/:userslug/bookmarks | DMW_URED | 08 | User saved post details read failed because of user not exists | DMW_UBMR08 | Failed to read user saved post details as user does not exist. Contact your system administrator. | Could not read saved post as user does not exists. Contact your system administrator. | |
/user/v1/create | UCRT | DMW_UCRT | 09 | Create user failed | DMW_UCRT09 | Failed to create user, there may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/user/v1/create | DMW_UCRT | 10 | Create user failed because of nodebb-plugin-sunbird-oidc plugin not enable | DMW_UCRT10 | Failed to create user, the nodebb plug-in or the API is not available. Contact your system administrator to enable it. | Could not create user. Try again later. | |
CATEGORY API's | |||||||
/category/:category_id/:slug | CDTL | DMW_CRED | 01 | Category details read failed. | DMW_CDTL01 | Failed to read category details, there may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read category details. Try again later. |
/category/:category_id/:slug | DMW_CRED | 02 | Category details read failed because of category id not exists. | DMW_CDTL02 | Failed to read category details, as category ID does not exists. Contact your system administrator. | Could not read category details. Try again later. | |
/category/:cid | CRED | DMW_CRED | 03 | Category details read by cid failed | DMW_CRED03 | Failed to read category cid details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not read category details. Try again later. |
/category/:cid | DMW_CRED | 04 | Category details read by cid failed because of cid not exists. | DMW_CRED04 | Failed to read category as cid details does not exists. Contact your system administrator to enable it. | Could not read category details. Try again later. | |
/categories | CLST | DMW_CRED | 05 | Access list of categories failed. | DMW_CLST05 | Failed to access category list. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not access category list. Try again later. |
/v2/categories | CCRT | DMW_CCRT | 06 | Create category failed | DMW_CCRT06 | Failed to create category. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create category. Try again later. |
/v2/categories | DMW_CCRT | 07 | Create category failed because of nodebb-plugin-write-api not enable. | DMW_CCRT07 | Failed to create category as nodebb-plugin write API is not enabled. Contact your system administrator. | Could not create category. Try again later. | |
/v2/categories | DMW_CCRT | 08 | Create category failed because of you are not authorized | DMW_CCRT08 | Failed to create category, unauthorised user. Contact your system administrator. | Could not create category. Try again later. | |
/v2/categories | DMW_CCRT | 09 | Create category failed because of request payload is incorrect. | DMW_CCRT09 | Failed to create category, mandatory fields are missing in the request. Enter the required values and resend the request. | Could not create category. Try again later. | |
/v2/categories/:cid(PUT) | CUDT | DMW_CUDT | 10 | Update category failed | DMW_CUDT10 | Failed to update category, there may be a network error or there are too many concurrent calls to the server. Try again later. | Could not update category. Try again later. |
/v2/categories/:cid(PUT) | DMW_CUDT | 11 | Update category failed because of nodebb-plugin-write-api not enable or cid not exists. | DMW_CUDT11 | Failed to update category as nodebb-plugin write API is not enabled or cid does not exists. Contact your system administrator to enable it. | Could not update category. Try again later. | |
/v2/categories/:cid(PUT) | DMW_CUDT | 12 | Update category failed because of you are not authorized | DMW_CUDT12 | Failed to update category, unauthorised user. Contact your system administrator. | Could not update category, unautorised user. Contact your system administrator. | |
/v2/categories/:cid(PUT) | DMW_CUDT | 13 | Update category failed because of request payload is incorrect. | DMW_CUDT13 | Failed to update category, mandatory fields are missing in the request. Enter the required values and resend the request. | Could not update category. Try again later. | |
/v2/categories/:cid(DELETE) | CDEL | DMW_CDEL | 14 | Delete category failed | DMW_CDEL14 | Failed to delete category. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not delete category. Try again later. |
/v2/categories/:cid(DELETE) | DMW_CDEL | 15 | Delete category failed because of nodebb-plugin-write-api not enable or cid not exists. | DMW_CDEL15 | Failed to delete category as nodebb-plugin write API is not enabled or cid does not exists. Contact your system administrator to enable it. | Could not delete category. Try again later. | |
/v2/categories/:cid(DELETE) | 16 | Delete category failed because of you are not authorized | DMW_CDEL16 | Failed to delete category, unauthorised user. Contact your system administrator. | Could not delete category. Try again later. | ||
/category/list | CLST | DMW_CLST | 17 | Category list api failed | DMW_CLST17 | Failed to read category list API. The plugin might not be enabled for your instance. Contact your system administrator to enable it. | Could not read category list. Try again later. |
/category/list | CLST | DMW_CLST | 18 | Category id not found, Use correct cid. | DMW_CLST18 | Failed to read category as cid details does not exists. Contact your system administrator to enable it. | Could not read category. Try again later. |
TOPICS API's | |||||||
/unread | TUNR | DMW_TRED | 01 | Access unread topics failed | DMW_TUNR01 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/recent | TRCT | DMW_TRED | 02 | Access recent topics failed. | DMW_TRCT02 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/topic/:topic_id/:slug | TDTL | DMW_TRED | 03 | Access topic details failed | DMW_TDTL03 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/topic/:topic_id/:slug | DMW_TRED | 04 | Access topic details failed because of topic id is not exists | DMW_TDTL04 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics | TCRT | DMW_TCRT | 05 | Create topic failed | DMW_TCRT05 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/v2/topics | DMW_TCRT | 06 | Create topic failed because of nodebb-plugin-write-api plugin not enabled. | DMW_TCRT06 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics | DMW_TCRT | 07 | Create topic failed because of you are not authorized. | DMW_TCRT07 | Could not create user. Try again later. | ||
/v2/topics | DMW_TCRT | 08 | Create topic failed because of request payload is incorrect. | DMW_TCRT08 | Could not create user. Try again later. | ||
/v2/topics/:tid(POST) | RCRT | DMW_RCRT | 09 | Add reply failed | DMW_RCRT09 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/topics/:tid(POST) | DMW_RCRT | 10 | Add reply failed because f nodebb-plugin-write-api is not enabled or tid not exists | DMW_RCRT10 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/topics/:tid(POST) | DMW_RCRT | 11 | Add reply failed because you are not authorized | DMW_RCRT11 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics/:tid(POST) | DMW_RCRT | 12 | Add reply failed because of request payload is incorrect. | DMW_RCRT12 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics/:tid(PUT) | TUDT | DMW_TUDT | 13 | Update topics/reply failed | DMW_TUDT13 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/v2/topics/:tid(PUT) | DMW_TUDT | 14 | Update topics/reply failed because of nodebb-plugin-write-api is not enabled or tid not exists. | DMW_TUDT14 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics/:tid(PUT) | DMW_TUDT | 15 | Update topics/reply failed because of you are not authorized | DMW_TUDT15 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics/:tid(PUT) | DMW_TUDT | 16 | Update topics/reply failed because of request payload is incorrect. | DMW_TUDT16 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/topics/:tid(DELETE) | TDEL | DMW_TDEL | 17 | Delete topic/reply failed | DMW_TDEL17 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/topics/:tid(DELETE) | DMW_TDEL | 18 | Delete topic/reply failed because of nodebb-plugin-write-api is not enabled or tid not exists | DMW_TDEL18 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/topics/:tid(DELETE) | DMW_TDEL | 19 | Delete topic/reply failed because of you are not authorized | DMW_TDEL19 | Failed to delete topic details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/topics/:tid(DELETE) | DMW_TDEL | 20 | Delete topic/reply failed because of tid is not exists. | DMW_TDEL20 | Failed to delete topic/reply. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
POST API's | |||||||
/post/pid/:pid | PRED | DWM_PRED | 01 | Access post details failed | DWM_PRED01 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/post/pid/:pid | DWM_PRED | 02 | Access post details failed because of pid is not exists | DWM_PRED02 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/posts/:pid(POST) | PCRT | DMW_PCRT | 03 | Create post failed | DMW_PCRT03 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid(POST) | DMW_PCRT | 04 | Create post failed because of nodebb-plugin-write-api is not enabled or pid not exists | DMW_PCRT04 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid(POST) | DMW_PCRT | 05 | Create post failed because of you are not authorized | DMW_PCRT05 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/posts/:pid(POST) | DMW_PCRT | 06 | Create post failed because of request payload is incorrect | DMW_PCRT06 | Failed to create post . There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid(DELETE) | PDEL | DWM_PDEL | 07 | Delete post failed | DWM_PDEL07 | Failed to delete post. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid(DELETE) | DWM_PDEL | 08 | Delete post failed because of nodebb-plugin-write-api is not enabled or pid not exists | DWM_PDEL08 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/posts/:pid(DELETE) | DWM_PDEL | 09 | Delete post failed because of you are not authorized | DWM_PDEL09 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid(DELETE) | DWM_PDEL | 10 | Delete post failed because of pid is not exists | DWM_PDEL10 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(POST) | PVOT | DMW_PCRT | 11 | Adding vote to a post failed | DMW_PVOT11 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/v2/posts/:pid/vote(POST) | DMW_PCRT | 12 | Adding vote to a post failed because of nodebb-plugin-write-api is not enabled or pid not exists | DMW_PVOT12 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(POST) | DMW_PCRT | 13 | Adding vote to a post failed because of you are not authorized | DMW_PVOT13 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(POST) | DMW_PCRT | 14 | Adding vote to a post failed because of request payload is incorrect | DMW_PVOT14 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(DELETE) | PVDL | DMW_PCRT | 15 | Deleting vote failed | DMW_PVDL15 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/vote(DELETE) | DMW_PCRT | 16 | Deleting vote failed because of nodebb-plugin-write-api is not enabled or pid not exists | DMW_PVDL16 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(DELETE) | DMW_PCRT | 17 | Deleting vote failed because of you are not authorized | DMW_PVDL17 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. | |
/v2/posts/:pid/vote(DELETE) | DMW_PCRT | 18 | Deleting vote failed because of pid is incorrect | DMW_PVDL18 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. | |
/v2/posts/:pid/bookmark(POST) | PSVE | DMW_PCRT | 19 | Bookmark post failed | DMW_PSVE19 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(POST) | PSVE | DMW_PCRT | 20 | Bookmark post failed because of nodebb-plugin-write-api not enabled or pid not exists | DMW_PSVE20 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(POST) | PSVE | DMW_PCRT | 21 | Bookmark post failed because of you are not authorized | DMW_PSVE21 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(POST) | PSVE | DMW_PCRT | 22 | Bookmark post failed because of pid is incorrect | DMW_PSVE22 | Failed to read user down vote post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(DELETE) | PUSVE | DMW_PCRT | 23 | Delete bookmark failed | DMW_PUSVE23 | Failed to read user down vote post details as user does not exist. Contact your system administrator. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(DELETE) | PUSVE | DMW_PCRT | 24 | Delete bookmark failed because of nodebb-plugin-write-api is not enabled or pid incorrect. | DMW_PUSVE24 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(DELETE) | PUSVE | DMW_PCRT | 25 | Delete bookmark failed because of you are not authorized | DMW_PUSVE25 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
/v2/posts/:pid/bookmark(DELETE) | PUSVE | DMW_PCRT | 26 | Delete bookmark failed because of pid not exists | DMW_PUSVE26 | Failed to read saved post details. There may be a network error or there are too many concurrent calls to the server. Try again later. | Could not create user. Try again later. |
The copy privileges failed as nodebb plugin in not enabled for your instance. Contact your system administrator to enable it. | Could not create user. Try again later. |
Could not create user. Try again later.Error Code Json:
{ "/discussion/forum/v2/read": { "post": { "endPoint": "/discussion/forum/v2/read", "key": "DiscussionForumRead", "errorObject": { "err_404": { "errMsg": "Forum read failed because of nodebb-plugin-create-forum plugin not enabled.", "err": "DMW_FRED01" }, "err_400": { "errMsg": "Forum read failed because of request payload issue", "err": "DMW_FRED02" }, "err_500": { "errMsg": "Forum read failed", "err": "DMW_FRED03" } } } }, "/discussion/forum/v2/create": { "post": { "endPoint": "/discussion/forum/v2/create", "key": "DiscussionForumCreate", "errorObject": { "err_404": { "errMsg": "Forum create failed because nodebb-plugin-create-forum not enabled", "err": "DMW_FCRT04" }, "err_400": { "errMsg": "Forum create failed because of request payload issue.", "err": "DMW_FCRT05" }, "err_500": { "errMsg": "Forum create failed", "err": "DMW_FCRT06" } } } }, "/discussion/forum/v2/remove": { "post": { "endPoint": "/discussion/forum/v2/remove", "key": "DiscussionForumRemove", "errorObject": { "err_404": { "errMsg": "Forum remove failed because nodebb-plugin-create-forum not enabled.", "err": "DMW_FREM07" }, "err_400": { "errMsg": "Forum remove failed because of request pay is incorrect", "err": "DMW_FREM09" }, "err_500": { "errMsg": "Forum remove failed", "err": "DMW_FREM08" } } } }, "/discussion/tags": { "get": { "endPoint": "/discussion/tags", "key": "DiscussionForumTagsList", "errorObject": { "err_500": { "errMsg": "Tags read failed", "err": "DMW_TRED01" } } } }, "/discussion/user/:userslug": { "get": { "endPoint": "/discussion/user/:userslug", "key": "DiscussionForumUserDetails", "errorObject": { "err_500": { "errMsg": "Tags read failed", "err": "DMW_URED01" }, "err_404": { "errMsg": "Users details read failed because of user not exists", "err": "DMW_URED02" } } } }, "/discussion/user/:userslug/upvoted": { "get": { "endPoint": "/discussion/user/:userslug/upvoted", "key": "DiscussionForumUserUpvoteDetails", "errorObject": { "err_500": { "errMsg": "User up vote post details read failed ", "err": "DMW_UUVR03" }, "err_404": { "errMsg": "User up vote post details read failed because of user not exists", "err": "DMW_UUVR04" } } } }, "/discussion/user/:userslug/downvoted": { "get": { "endPoint": "/discussion/user/:userslug/downvoted", "key": "DiscussionForumUserDownvoteDetails", "errorObject": { "err_500": { "errMsg": "User down vote post details read failed", "err": "DMW_UDVR05" }, "err_404": { "errMsg": "User down vote post details read failed because of user not exists.", "err": "DMW_UDVR06" } } } }, "/discussion/user/:userslug/bookmarks": { "get": { "endPoint": "/discussion/user/:userslug/bookmarks", "key": "DiscussionForumUserBookmarksDetails", "errorObject": { "err_500": { "errMsg": "User saved post details read failed", "err": "DMW_UBMR07" }, "err_404": { "errMsg": "User saved post details read failed because of user not exists", "err": "DMW_UBMR08" } } } }, "/discussion/user/v1/create": { "post": { "endPoint": "/discussion/user/v1/create", "key": "DiscussionForumCreate", "errorObject": { "err_500": { "errMsg": "Create user failed", "err": "DMW_UCRT09" }, "err_404": { "errMsg": "Create user failed because of nodebb-plugin-sunbird-oidc plugin not enable", "err": "DMW_UCRT10" } } } }, "/discussion/category/:category_id/:slug": { "get": { "endPoint": "/discussion/category/:category_id/:slug", "key": "DiscussionForumCategoryDetails", "errorObject": { "err_500": { "errMsg": "Category details read failed", "err": "DMW_CDTL01" }, "err_404": { "errMsg": "Category details read failed because of category id not exists.", "err": "DMW_CDTL02" } } } }, "/discussion/category/:cid": { "get": { "endPoint": "/discussion/category/:cid", "key": "DiscussionForumCategoryDetailsByCid", "errorObject": { "err_500": { "errMsg": "Category details read by cid failed", "err": "DMW_CRED03" }, "err_404": { "errMsg": "Category details read by cid failed because of cid not exists.", "err": "DMW_CRED04" } } } }, "/discussion/categories": { "get": { "endPoint": "/discussion/categories", "key": "DiscussionForumCategoryList", "errorObject": { "err_500": { "errMsg": "Access list of categories failed.", "err": "DMW_CLST05" } } } }, "/discussion/v2/categories": { "get": { "endPoint": "/discussion/v2/categories", "key": "DiscussionForumCreateCategory", "errorObject": { "err_500": { "errMsg": "Create category failed", "err": "DMW_CCRT06" }, "err_404": { "errMsg": "Create category failed because of nodebb-plugin-write-api not enable.", "err": "DMW_CCRT07" }, "err_401": { "errMsg": "Create category failed because of you are not authorized", "err": "DMW_CCRT08" }, "err_400": { "errMsg": "Create category failed because of request payload is incorrect.", "err": "DMW_CCRT09" } } } }, "/discussion/v2/categories/:cid": { "post": { "endPoint": "/discussion/v2/categories/:cid", "key": "DiscussionForumUpdateCategory", "errorObject": { "err_500": { "errMsg": "Update category failed", "err": "DMW_CUDT10" }, "err_404": { "errMsg": "Update category failed because of nodebb-plugin-write-api not enable or cid not exists.", "err": "DMW_CUDT11" }, "err_401": { "errMsg": "Update category failed because of you are not authorized", "err": "DMW_CUDT12" }, "err_400": { "errMsg": "Update category failed because of request payload is incorrect.", "err": "DMW_CUDT13" } }, "delete": { "endPoint": "/discussion/v2/categories/:cid", "key": "DiscussionForumDeleteCategory", "errorObject": { "err_500": { "errMsg": "Delete category failed", "err": "DMW_CDEL14" }, "err_404": { "errMsg": "Delete category failed because of nodebb-plugin-write-api not enable or cid not exists.", "err": "DMW_CDEL15" }, "err_401": { "errMsg": "Delete category failed because of you are not authorized", "err": "DMW_CDEL16" } } } }, "/discussion/unread": { "get": { "endPoint": "/discussion/unread", "key": "DiscussionForumUnreadTopics", "errorObject": { "err_500": { "errMsg": "Access unread topics failed", "err": "DMW_TUNR01" } } } }, "/discussion/recent": { "get": { "endPoint": "/discussion/recent", "key": "DiscussionForumRecentopics", "errorObject": { "err_500": { "errMsg": "Access recent topics failed.", "err": "DMW_TRCT02" } } } }, "/discussion/topic/:topic_id/:slug": { "get": { "endPoint": "/discussion/topic/:topic_id/:slug", "key": "DiscussionForumTopicDetails", "errorObject": { "err_500": { "errMsg": "Access topic details failed", "err": "DMW_TDTL03" }, "err_404": { "errMsg": "Access topic details failed because of topic id is not exists", "err": "DMW_TDTL04" } } } }, "/discussion/v2/topics": { "post": { "endPoint": "/discussion/v2/topics", "key": "DiscussionForumCreateTopic", "errorObject": { "err_500": { "errMsg": "Create topic failed", "err": "DMW_TCRT05" }, "err_404": { "errMsg": "Create topic failed because of nodebb-plugin-write-api plugin not enabled.", "err": "DMW_TCRT06" }, "err_401": { "errMsg": "Create topic failed because of you are not authorized.", "err": "DMW_TCRT07" }, "err_400": { "errMsg": "Create topic failed because of request payload is incorrect.", "err": "DMW_TCRT08" } } } }, "/discussion/v2/topics/:tid": { "post": { "endPoint": "/discussion/v2/topics/:tid", "key": "DiscussionForumAddReplyToTopic", "errorObject": { "err_500": { "errMsg": "Add reply failed", "err": "DMW_RCRT09" }, "err_404": { "errMsg": "Add reply failed because f nodebb-plugin-write-api is not enabled or tid not exists", "err": "DMW_RCRT10" }, "err_401": { "errMsg": "Add reply failed because you are not authorized", "err": "DMW_RCRT11" }, "err_400": { "errMsg": "Add reply failed because of request payload is incorrect.", "err": "DMW_RCRT12" } } }, "put": { "endPoint": "/discussion/v2/topics/:tid", "key": "DiscussionForumUpdateTopic", "errorObject": { "err_500": { "errMsg": "Update topics/reply failed", "err": "DMW_TUDT13" }, "err_404": { "errMsg": "Update topics/reply failed because of nodebb-plugin-write-api is not enabled or tid not exists.", "err": "DMW_TUDT14" }, "err_401": { "errMsg": "Update topics/reply failed because of you are not authorized", "err": "DMW_TUDT15" }, "err_400": { "errMsg": "Update topics/reply failed because of request payload is incorrect", "err": "DMW_TUDT16" } } }, "delete": { "endPoint": "/discussion/v2/topics/:tid", "key": "DiscussionForumDeleteTopic", "errorObject": { "err_500": { "errMsg": "Delete topic/reply failed", "err": "DMW_TDEL17" }, "err_404": { "errMsg": "Delete topic/reply failed because of nodebb-plugin-write-api is not enabled or tid not exists", "err": "DMW_TDEL18" }, "err_401": { "errMsg": "Delete topic/reply failed because of you are not authorized", "err": "DMW_TDEL19" }, "err_400": { "errMsg": "Delete topic/reply failed because of tid is not exists", "err": "DMW_TDEL20" } } } }, "/discussion/post/pid/:pid": { "get": { "endPoint": "/discussion/post/pid/:pid", "key": "DiscussionForumPostDetails", "errorObject": { "err_500": { "errMsg": "Access post details failed", "err": "DWM_PRED01" }, "err_404": { "errMsg": "Access post details failed because of pid is not exists", "err": "DWM_PRED02" } } } }, "/discussion/v2/posts/:pid": { "post": { "endPoint": "/discussion/v2/posts/:pid", "key": "DiscussionForumCreatePost", "errorObject": { "err_500": { "errMsg": "Create post failed", "err": "DMW_PCRT03" }, "err_404": { "errMsg": "Create post failed because of nodebb-plugin-write-api is not enabled or pid not exists", "err": "DMW_PCRT04" }, "err_401": { "errMsg": "Create post failed because of you are not authorized", "err": "DMW_PCRT05" }, "err_400": { "errMsg": "Create post failed because of request payload is incorrect", "err": "DMW_PCRT06" } } }, "delete": { "endPoint": "/discussion/v2/posts/:pid", "key": "DiscussionForumDeletePost", "errorObject": { "err_500": { "errMsg": "Delete post failed", "err": "DMW_PCRT07" }, "err_404": { "errMsg": "Delete post failed because of nodebb-plugin-write-api is not enabled or pid not exists", "err": "DMW_PCRT08" }, "err_401": { "errMsg": "Delete post failed because of you are not authorized", "err": "DMW_PCRT09" }, "err_400": { "errMsg": "Delete post failed because of pid is not exists", "err": "DMW_PCRT10" } } } }, "/discussion/v2/posts/:pid/vote": { "post": { "endPoint": "/discussion/v2/posts/:pid/vote", "key": "DiscussionForumCreatePost", "errorObject": { "err_500": { "errMsg": "Adding vote to a post failed", "err": "DMW_PVOT11" }, "err_404": { "errMsg": "Adding vote to a post failed because of nodebb-plugin-write-api is not enabled or pid not exists", "err": "DMW_PVOT12" }, "err_401": { "errMsg": "Adding vote to a post failed because of you are not authorized", "err": "DMW_PVOT13" }, "err_400": { "errMsg": "Adding vote to a post failed because of request payload is incorrect", "err": "DMW_PVOT14" } } }, "delete": { "endPoint": "/discussion/v2/posts/:pid/vote", "key": "DiscussionForumDeletePost", "errorObject": { "err_500": { "errMsg": "Deleting vote failed", "err": "DMW_PVDL15" }, "err_404": { "errMsg": "Deleting vote failed because of nodebb-plugin-write-api is not enabled or pid not exists", "err": "DMW_PVDL16" }, "err_401": { "errMsg": "Deleting vote failed because of you are not authorized", "err": "DMW_PVDL17" }, "err_400": { "errMsg": "Deleting vote failed because of pid is incorrect", "err": "DMW_PVDL18" } } } }, "/discussion/v2/posts/:pid/bookmark": { "post": { "endPoint": "/discussion/v2/posts/:pid/bookmark", "key": "DiscussionForumSavePost", "errorObject": { "err_500": { "errMsg": "Bookmark post failed", "err": "DMW_PSVE19" }, "err_404": { "errMsg": "Bookmark post failed because of nodebb-plugin-write-api not enabled or pid not exists", "err": "DMW_PSVE20" }, "err_401": { "errMsg": "Bookmark post failed because of you are not authorized", "err": "DMW_PSVE21" }, "err_400": { "errMsg": "Bookmark post failed because of pid is incorrect", "err": "DMW_PSVE22" } } }, "delete": { "endPoint": "/discussion/v2/posts/:pid/bookmark", "key": "DiscussionForumUnsavePost", "errorObject": { "err_500": { "errMsg": "Delete bookmark failed", "err": "DMW_PUSVE23" }, "err_404": { "errMsg": "Delete bookmark failed because of nodebb-plugin-write-api is not enabled or pid incorrect.", "err": "DMW_PSVE24" }, "err_401": { "errMsg": "Delete bookmark failed because of you are not authorized", "err": "DMW_PSVE25" }, "err_400": { "errMsg": "Delete bookmark failed because of pid not exists", "err": "DMW_PSVE26" } } } } } }
Challenges:
We can not tract nodebb api errors, because we are only accessing nodebb api, we not doing code changes.
We can track only discussion forum Errors and Portal Errors. But In Middleware and Portal backend we are doing proxy calls only, so we can tract only code issues instead of actual api issues.
How to get proper error code for a particular api in discussion middleware?
To get the proper error code for a particular api, we are maintain a json object like below
{ '/discussions/forum/v2/read': { 'errorMsg': "Forum read api failed because of plugin not enabled", 'err': "DMW_FRED01" }, '/discussions/forum/v2/creat': { 'errorMsg': "Forum creat api failed because of plugin not enabled", 'err': "DMW_FCRT02" }, '/discussions/v2/topic': { 'errorMsg': "Create topic failed", 'err': "DMW_TCRT17" }, ..... ..... ..... }
in Proxy object we are mapping the error code like below
**** Import Error Json file here as errorCodes ***** app.post(`${BASE_REPORT_URL}/forum/v2/read`, proxyObject()); app.post(`${BASE_REPORT_URL}/forum/v2/create`, proxyObject()); app.post(`${BASE_REPORT_URL}/v2/topics`, proxyObject()); function proxyObject() { return proxy(nodebbServiceUrl, { proxyReqOptDecorator: proxyUtils.decorateRequestHeaders(), proxyReqPathResolver: function (req) { let urlParam = req.originalUrl.replace('/discussion', ''); let query = require('url').parse(req.url).query; if (query) { return require('url').parse(nodebbServiceUrl+ urlParam + '?' + query).path } else { const incomingUrl = req.protocol + '://' + req.get('host') + req.originalUrl; const proxyUrl = require('url').parse(nodebbServiceUrl + urlParam); return proxyUrl.path; } }, userResDecorator: (proxyRes, proxyResData, req, res) => { try { const data = (proxyResData.toString('utf8')); if (proxyRes.statusCode === 404 ) { return data; } else { return proxyUtils.handleSessionExpiry(proxyRes, proxyResData, req, res, data); } } catch (err) { *** Here is mapping happned const errorObj = errorCodes[req.originalUrl]; { "id": "discussion.forum.middleware", "ver": "1.0", "ts": "2020-11-25T07:18:09.945Z", "params": { "resmsgid": "5f36c090-2eee-11eb-80ed-6bb70096c082", "msgid": "req.headers['x-requester-id']", "status": "failed", "err": errorObj.err, "errmsg": errorObj .errorMsg } } *** return proxyUtils.handleSessionExpiry(proxyRes, proxyResData, req, res); } } }) }