mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(FileMaker Node): Improve returned error responses (#6585)
This commit is contained in:
@@ -70,13 +70,22 @@ export async function getToken(
|
||||
if (typeof response === 'string') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
'DataAPI response body is not valid JSON. Is the DataAPI enabled?',
|
||||
);
|
||||
}
|
||||
|
||||
return response.response.token;
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
let message
|
||||
if ( error.statusCode === 502 ) {
|
||||
message = 'The server is not responding. Is the DataAPI enabled?'
|
||||
}
|
||||
else if (error.error ) {
|
||||
message = error.error.messages[0].code + ' - ' + error.error.messages[0].message
|
||||
} else {
|
||||
message = error.message;
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,25 +266,8 @@ export async function logout(
|
||||
//rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await this.helpers.request(requestOptions);
|
||||
|
||||
if (typeof response === 'string') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Response body is not valid JSON. Change "Response Format" to "String"',
|
||||
);
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
const errorMessage = `${error.response.body.messages[0].message}'(' + ${error.response.body.messages[0].message}')'`;
|
||||
|
||||
if (errorMessage !== undefined) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
throw error.response.body;
|
||||
}
|
||||
const response = await this.helpers.request(requestOptions);
|
||||
return response
|
||||
}
|
||||
|
||||
export function parseSort(this: IExecuteFunctions, i: number): object | null {
|
||||
|
||||
Reference in New Issue
Block a user