show cloud API errors

This commit is contained in:
SPRINX0\prochazka
2025-05-22 17:30:24 +02:00
parent 8bd4721686
commit c9638aefe9
2 changed files with 34 additions and 31 deletions

View File

@@ -237,7 +237,12 @@ async function callCloudApiGet(endpoint, signinHolder = null, additionalHeaders
...signinHeaders,
...additionalHeaders,
},
validateStatus: status => status < 500,
});
const { errorMessage } = resp.data;
if (errorMessage) {
return { apiErrorMessage: errorMessage };
}
return resp.data;
}
@@ -255,7 +260,12 @@ async function callCloudApiPost(endpoint, body, signinHolder = null) {
...getLicenseHttpHeaders(),
...signinHeaders,
},
validateStatus: status => status < 500,
});
const { errorMessage } = resp.data;
if (errorMessage) {
return { apiErrorMessage: errorMessage };
}
return resp.data;
}
@@ -275,10 +285,14 @@ async function getCloudContent(folid, cntid) {
const encryptor = simpleEncryptor.createEncryptor(signinHolder.encryptionKey);
const { content, name, type } = await callCloudApiGet(`content/${folid}/${cntid}`, signinHolder, {
const { content, name, type, apiErrorMessage } = await callCloudApiGet(`content/${folid}/${cntid}`, signinHolder, {
'x-kehid': signinHolder.kehid,
});
if (apiErrorMessage) {
return { apiErrorMessage };
}
return {
content: encryptor.decrypt(content),
name,
@@ -294,7 +308,7 @@ async function putCloudContent(folid, cntid, content, name, type) {
const encryptor = simpleEncryptor.createEncryptor(signinHolder.encryptionKey);
await callCloudApiPost(
const resp = await callCloudApiPost(
`put-content`,
{
folid,
@@ -307,6 +321,7 @@ async function putCloudContent(folid, cntid, content, name, type) {
signinHolder
);
socket.emitChanged('cloud-content-changed');
return resp;
}
const cloudConnectionCache = {};