MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / onToolError

Method onToolError

packages/components/src/handler.ts:1893–1965  ·  view source on GitHub ↗
(returnIds: ICommonObject, error: string | object)

Source from the content-addressed store, hash-verified

1891 }
1892
1893 async onToolError(returnIds: ICommonObject, error: string | object) {
1894 if (Object.prototype.hasOwnProperty.call(this.handlers, 'langSmith')) {
1895 const toolRun: RunTree | undefined = this.handlers['langSmith'].toolRun[returnIds['langSmith'].toolRun]
1896 if (toolRun) {
1897 await toolRun.end({
1898 error: {
1899 error
1900 }
1901 })
1902 await toolRun.patchRun()
1903 }
1904 }
1905
1906 if (Object.prototype.hasOwnProperty.call(this.handlers, 'langFuse')) {
1907 const toolSpan: LangfuseSpanClient | undefined = this.handlers['langFuse'].toolSpan[returnIds['langFuse'].toolSpan]
1908 if (toolSpan) {
1909 toolSpan.end({
1910 output: error
1911 })
1912 }
1913 }
1914
1915 if (Object.prototype.hasOwnProperty.call(this.handlers, 'lunary')) {
1916 const toolEventId: string = this.handlers['lunary'].toolEvent[returnIds['lunary'].toolEvent]
1917 const monitor = this.handlers['lunary'].client
1918
1919 if (monitor && toolEventId) {
1920 await monitor.trackEvent('tool', 'end', {
1921 runId: toolEventId,
1922 output: error
1923 })
1924 }
1925 }
1926
1927 if (Object.prototype.hasOwnProperty.call(this.handlers, 'langWatch')) {
1928 const span: LangWatchSpan | undefined = this.handlers['langWatch'].span[returnIds['langWatch'].span]
1929 if (span) {
1930 span.end({
1931 error
1932 })
1933 }
1934 }
1935
1936 if (Object.prototype.hasOwnProperty.call(this.handlers, 'arize')) {
1937 const toolSpan: Span | undefined = this.handlers['arize'].toolSpan[returnIds['arize'].toolSpan]
1938 if (toolSpan) {
1939 toolSpan.setAttribute('error.value', JSON.stringify(error))
1940 toolSpan.setAttribute('error.mime_type', 'application/json')
1941 toolSpan.setStatus({ code: SpanStatusCode.ERROR, message: error.toString() })
1942 toolSpan.end()
1943 }
1944 }
1945
1946 if (Object.prototype.hasOwnProperty.call(this.handlers, 'phoenix')) {
1947 const toolSpan: Span | undefined = this.handlers['phoenix'].toolSpan[returnIds['phoenix'].toolSpan]
1948 if (toolSpan) {
1949 toolSpan.setAttribute('error.value', JSON.stringify(error))
1950 toolSpan.setAttribute('error.mime_type', 'application/json')

Callers 3

runMethod · 0.45
promiseMethod · 0.45
handleToolSubmissionFunction · 0.45

Calls 2

stringifyMethod · 0.80
callMethod · 0.45

Tested by

no test coverage detected