mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
fix: fix crash when custom id data is not valid JSON
This commit is contained in:
parent
d93097306c
commit
ef78fbc065
1 changed files with 13 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
|||
import { logger } from "../logger";
|
||||
|
||||
const customIdFormat = /^([^:]+):\d+:(.*)$/;
|
||||
|
||||
export function parseCustomId(customId: string): { namespace: string; data: any } {
|
||||
|
@ -9,6 +11,17 @@ export function parseCustomId(customId: string): { namespace: string; data: any
|
|||
};
|
||||
}
|
||||
|
||||
let parsedData: any;
|
||||
try {
|
||||
parsedData = JSON.parse(parts[2]);
|
||||
} catch (err) {
|
||||
logger.debug(`Error while parsing custom id data (custom id: ${customId}): ${String(err)}`);
|
||||
return {
|
||||
namespace: "",
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
namespace: parts[1],
|
||||
// Skipping timestamp
|
||||
|
|
Loading…
Add table
Reference in a new issue