adding error message when created message has wrong header format (#2033)
This commit is contained in:
parent
7211a18b57
commit
7ba10c1b7a
1 changed files with 8 additions and 2 deletions
|
@ -102,8 +102,14 @@ const SendMessage: React.FC = () => {
|
|||
}) => {
|
||||
if (messageSchema) {
|
||||
const { partition, key, content } = data;
|
||||
const headers = data.headers ? JSON.parse(data.headers) : undefined;
|
||||
const errors = validateMessage(key, content, messageSchema);
|
||||
if (data.headers) {
|
||||
try {
|
||||
JSON.parse(data.headers);
|
||||
} catch (error) {
|
||||
errors.push('Wrong header format');
|
||||
}
|
||||
}
|
||||
if (errors.length > 0) {
|
||||
const errorsHtml = errors.map((e) => `<li>${e}</li>`).join('');
|
||||
dispatch(
|
||||
|
@ -117,7 +123,7 @@ const SendMessage: React.FC = () => {
|
|||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const headers = data.headers ? JSON.parse(data.headers) : undefined;
|
||||
try {
|
||||
await messagesApiClient.sendTopicMessages({
|
||||
clusterName,
|
||||
|
|
Loading…
Add table
Reference in a new issue