mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(AWS DynamoDB Node): Improve error message parsing (#7793)
Github issue / Community forum post (link here to close automatically):
This commit is contained in:
parent
c72229fbe2
commit
5ba5ed8e3c
|
@ -37,9 +37,11 @@ export async function awsApiRequest(
|
||||||
(await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions)) as string,
|
(await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions)) as string,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage =
|
const statusCode = (error.statusCode || error.cause?.statusCode) as number;
|
||||||
|
let errorMessage =
|
||||||
error.response?.body?.message || error.response?.body?.Message || error.message;
|
error.response?.body?.message || error.response?.body?.Message || error.message;
|
||||||
if (error.statusCode === 403) {
|
|
||||||
|
if (statusCode === 403) {
|
||||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||||
throw new Error('The AWS credentials are not valid!');
|
throw new Error('The AWS credentials are not valid!');
|
||||||
} else if (
|
} else if (
|
||||||
|
@ -51,7 +53,13 @@ export async function awsApiRequest(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(`AWS error response [${error.statusCode}]: ${errorMessage}`);
|
if (error.cause?.error) {
|
||||||
|
try {
|
||||||
|
errorMessage = JSON.parse(error.cause?.error).message;
|
||||||
|
} catch (ex) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(`AWS error response [${statusCode}]: ${errorMessage}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue