mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix: simplified error response format for google tools
This commit is contained in:
+17
-17
@@ -130,23 +130,23 @@ export const createTool: ToolConfig<GoogleDocsToolParams, GoogleDocsCreateRespon
|
||||
throw error
|
||||
}
|
||||
},
|
||||
transformError: async (error) => {
|
||||
console.error('Google Docs create - Transform error:', error)
|
||||
|
||||
const errorMessage =
|
||||
typeof error === 'object' && error !== null
|
||||
? error.message || JSON.stringify(error, null, 2)
|
||||
: error.toString() || 'An error occurred while creating Google Docs document'
|
||||
|
||||
return {
|
||||
success: false,
|
||||
output: {
|
||||
metadata: {
|
||||
documentId: '',
|
||||
title: '',
|
||||
},
|
||||
},
|
||||
error: errorMessage,
|
||||
transformError: (error) => {
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while creating Google Docs document'
|
||||
},
|
||||
}
|
||||
|
||||
+17
-16
@@ -70,23 +70,24 @@ export const readTool: ToolConfig<GoogleDocsToolParams, GoogleDocsReadResponse>
|
||||
},
|
||||
}
|
||||
},
|
||||
transformError: async (error) => {
|
||||
const errorMessage =
|
||||
typeof error === 'object' && error !== null
|
||||
? error.message || JSON.stringify(error, null, 2)
|
||||
: error.toString() || 'An error occurred while reading Google Docs document'
|
||||
|
||||
return {
|
||||
success: false,
|
||||
output: {
|
||||
content: '',
|
||||
metadata: {
|
||||
documentId: '',
|
||||
title: '',
|
||||
},
|
||||
},
|
||||
error: errorMessage,
|
||||
transformError: (error) => {
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while reading Google Docs document'
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+17
-16
@@ -116,22 +116,23 @@ export const writeTool: ToolConfig<GoogleDocsToolParams, GoogleDocsWriteResponse
|
||||
throw error
|
||||
}
|
||||
},
|
||||
transformError: async (error) => {
|
||||
const errorMessage =
|
||||
typeof error === 'object' && error !== null
|
||||
? error.message || JSON.stringify(error, null, 2)
|
||||
: error.toString() || 'An error occurred while writing to Google Docs'
|
||||
|
||||
return {
|
||||
success: false,
|
||||
output: {
|
||||
updatedContent: false,
|
||||
metadata: {
|
||||
documentId: '',
|
||||
title: '',
|
||||
},
|
||||
},
|
||||
error: errorMessage,
|
||||
transformError: (error) => {
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while writing to Google Docs'
|
||||
},
|
||||
}
|
||||
|
||||
+16
-3
@@ -84,9 +84,22 @@ export const readTool: ToolConfig<GoogleSheetsToolParams, GoogleSheetsReadRespon
|
||||
return result
|
||||
},
|
||||
transformError: (error) => {
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
return JSON.stringify(error) || 'An error occurred while reading from Google Sheets'
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
return error.message || 'An error occurred while reading from Google Sheets'
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while reading from Google Sheets'
|
||||
},
|
||||
}
|
||||
|
||||
+17
-1
@@ -93,6 +93,22 @@ export const updateTool: ToolConfig<GoogleSheetsToolParams, GoogleSheetsUpdateRe
|
||||
return result
|
||||
},
|
||||
transformError: (error) => {
|
||||
return error.message || 'An error occurred while updating Google Sheets'
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while updating Google Sheets'
|
||||
},
|
||||
}
|
||||
|
||||
+17
-1
@@ -93,6 +93,22 @@ export const writeTool: ToolConfig<GoogleSheetsToolParams, GoogleSheetsWriteResp
|
||||
return result
|
||||
},
|
||||
transformError: (error) => {
|
||||
return error.message || 'An error occurred while writing to Google Sheets'
|
||||
// If it's an Error instance with a message, use that
|
||||
if (error instanceof Error) {
|
||||
return error.message
|
||||
}
|
||||
|
||||
// If it's an object with an error or message property
|
||||
if (typeof error === 'object' && error !== null) {
|
||||
if (error.error) {
|
||||
return typeof error.error === 'string' ? error.error : JSON.stringify(error.error)
|
||||
}
|
||||
if (error.message) {
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
// Default fallback message
|
||||
return 'An error occurred while writing to Google Sheets'
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user