(interaction, error, errorType, context = {})
| 149 | } |
| 150 | |
| 151 | function buildErrorLogData(interaction, error, errorType, context = {}) { |
| 152 | const resolvedErrorCode = resolveErrorCode({ error, errorType, context }); |
| 153 | const errorMetadata = getErrorMetadata(resolvedErrorCode); |
| 154 | const traceId = context.traceId || interaction?.traceContext?.traceId || interaction?.traceId || error?.context?.traceId; |
| 155 | |
| 156 | return { |
| 157 | logData: { |
| 158 | event: 'interaction.error', |
| 159 | errorCode: resolvedErrorCode, |
| 160 | remediationHint: errorMetadata.remediation, |
| 161 | severity: errorMetadata.severity, |
| 162 | retryable: errorMetadata.retryable, |
| 163 | error: error.message, |
| 164 | type: errorType, |
| 165 | traceId, |
| 166 | guildId: interaction?.guildId, |
| 167 | userId: interaction?.user?.id, |
| 168 | command: interaction?.commandName || context.command, |
| 169 | interaction: interaction ? { |
| 170 | type: interaction.type, |
| 171 | commandName: interaction.commandName, |
| 172 | customId: interaction.customId, |
| 173 | userId: interaction.user?.id, |
| 174 | guildId: interaction.guildId, |
| 175 | channelId: interaction.channelId |
| 176 | } : undefined, |
| 177 | context |
| 178 | }, |
| 179 | traceId, |
| 180 | resolvedErrorCode, |
| 181 | errorMetadata |
| 182 | }; |
| 183 | } |
| 184 | |
| 185 | function logInteractionError(error, errorType, logData) { |
| 186 | const isUserError = [ |
no test coverage detected