mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(OpenAI Node): Descriptive errors (#6270)
This commit is contained in:
18
packages/nodes-base/nodes/OpenAi/GenericFunctions.ts
Normal file
18
packages/nodes-base/nodes/OpenAi/GenericFunctions.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import type {
|
||||
IExecuteSingleFunctions,
|
||||
IN8nHttpFullResponse,
|
||||
INodeExecutionData,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function sendErrorPostReceive(
|
||||
this: IExecuteSingleFunctions,
|
||||
data: INodeExecutionData[],
|
||||
response: IN8nHttpFullResponse,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
if (String(response.statusCode).startsWith('4') || String(response.statusCode).startsWith('5')) {
|
||||
throw new NodeApiError(this.getNode(), response as unknown as JsonObject);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user