diff --git a/packages/nodes-base/nodes/Code/PythonSandbox.ts b/packages/nodes-base/nodes/Code/PythonSandbox.ts index 13a3bb6228..365f213500 100644 --- a/packages/nodes-base/nodes/Code/PythonSandbox.ts +++ b/packages/nodes-base/nodes/Code/PythonSandbox.ts @@ -1,4 +1,4 @@ -import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow'; +import { ApplicationError, type IExecuteFunctions, type INodeExecutionData } from 'n8n-workflow'; import type { PyDict } from 'pyodide/ffi'; import { LoadPyodide } from './Pyodide'; import type { SandboxContext } from './Sandbox'; @@ -97,7 +97,9 @@ await __main()`; private getPrettyError(error: PyodideError): Error { const errorTypeIndex = error.message.indexOf(error.type); if (errorTypeIndex !== -1) { - return new Error(error.message.slice(errorTypeIndex)); + return new ApplicationError(error.message.slice(errorTypeIndex), { + level: ['TypeError', 'AttributeError'].includes(error.type) ? 'warning' : 'error', + }); } return error;