MCPcopy
hub / github.com/simstudioai/sim / notifyBlockError

Function notifyBlockError

apps/sim/stores/terminal/console/store.ts:260–299  ·  view source on GitHub ↗
({
  error,
  blockName,
  blockId,
  executionId,
  logContext,
}: NotifyBlockErrorParams)

Source from the content-addressed store, hash-verified

258const recentErrorNotifications = new Map<string, number>()
259
260const notifyBlockError = ({
261 error,
262 blockName,
263 blockId,
264 executionId,
265 logContext,
266}: NotifyBlockErrorParams) => {
267 const settings = getQueryClient().getQueryData<GeneralSettings>(generalSettingsKeys.settings())
268 const isErrorNotificationsEnabled = settings?.errorNotificationsEnabled ?? true
269
270 if (!isErrorNotificationsEnabled) return
271
272 try {
273 const errorMessage = normalizeConsoleError(error) ?? String(error)
274 const displayName = blockName || 'Unknown Block'
275 const copilotMessage = `${errorMessage}\n\nError in ${displayName}.\n\nPlease fix this.`
276
277 const now = Date.now()
278 for (const [key, shownAt] of recentErrorNotifications) {
279 if (now - shownAt >= NOTIFY_DEDUP_WINDOW_MS) recentErrorNotifications.delete(key)
280 }
281 const dedupKey = `${getBlockExecutionKey(blockId, executionId)}: ${errorMessage}`
282 const lastShownAt = recentErrorNotifications.get(dedupKey)
283 if (lastShownAt !== undefined && now - lastShownAt < NOTIFY_DEDUP_WINDOW_MS) return
284 recentErrorNotifications.set(dedupKey, now)
285
286 toast.error(displayName, {
287 description: errorMessage,
288 action: {
289 label: 'Fix in Chat',
290 onClick: () => sendMothershipMessage(copilotMessage),
291 },
292 })
293 } catch (notificationError) {
294 logger.error('Failed to create block error notification', {
295 ...logContext,
296 error: notificationError,
297 })
298 }
299}
300
301export const useTerminalConsoleStore = create<ConsoleStore>()(
302 devtools((set, get) => ({

Callers 1

store.tsFile · 0.85

Calls 8

normalizeConsoleErrorFunction · 0.90
sendMothershipMessageFunction · 0.90
getQueryClientFunction · 0.85
getBlockExecutionKeyFunction · 0.85
errorMethod · 0.80
deleteMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected