Error format

Hello ! I'm testing to create a channel when the category is full. I get this error in a catch() of create():
{
"requestBody": {
"json": { ... }
},
"rawError": {
"message": "Invalid Form Body",
"code": 50035,
"errors": {
"parent_id": {
"_errors": [
{
"code": "CHANNEL_PARENT_MAX_CHANNELS",
"message": "Maximum number of channels in category reached (50)"
}
]
}
}
},
"code": 50035,
"status": 400,
"method": "POST",
"url": "///"
}
{
"requestBody": {
"json": { ... }
},
"rawError": {
"message": "Invalid Form Body",
"code": 50035,
"errors": {
"parent_id": {
"_errors": [
{
"code": "CHANNEL_PARENT_MAX_CHANNELS",
"message": "Maximum number of channels in category reached (50)"
}
]
}
}
},
"code": 50035,
"status": 400,
"method": "POST",
"url": "///"
}
Why I need to access to error.rawError.errors.parent_id._errors[0].code to get the error ? In a different situation, for example when I can't send a DM to a user, it's much clearer than that
5 Replies
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
grass
grass12mo ago
ask discord
Syjalo
Syjalo12mo ago
Because this is the invalid form body error and the error may occur in any of properties, in your case it's parent_id.
Mathias
MathiasOP12mo ago
The message itself is more complex : Invalid Form Body parent_id[CHANNEL_PARENT_MAX_CHANNELS]: Maximum number of channels in category reached (50) But it's strange not to have a clear message for this error. It's not really an Invalid Body Wa can know before if the category is full ?
Syjalo
Syjalo12mo ago
Check the count of children of the category
Want results from more Discord servers?
Add your server