feat: implement error handling and logging in server hooks to capture and notify on 404 and 500 errors, enhancing server reliability and monitoring
This commit is contained in:
@@ -859,6 +859,85 @@ export const criarTemplatesPadrao = mutation({
|
||||
],
|
||||
categoria: 'email' as const,
|
||||
tags: ['seguranca', 'anomalia', 'alerta', 'cybersecurity']
|
||||
},
|
||||
// ===================== NOTIFICAÇÕES DE ERROS DO SERVIDOR =====================
|
||||
{
|
||||
codigo: 'ERRO_SERVIDOR_404',
|
||||
nome: 'Erro 404 - Página Não Encontrada',
|
||||
titulo: '⚠️ Erro 404 - Página não encontrada',
|
||||
corpo:
|
||||
"<html><body style='font-family: Arial, sans-serif; line-height: 1.6; color: #333;'>" +
|
||||
"<div style='max-width: 600px; margin: 0 auto; padding: 20px;'>" +
|
||||
"<h2 style='color: #F59E0B;'>⚠️ Erro 404 - Página Não Encontrada</h2>" +
|
||||
'<p>Olá <strong>{{destinatarioNome}}</strong>,</p>' +
|
||||
'<p>O sistema detectou uma tentativa de acesso a uma página que não existe:</p>' +
|
||||
"<div style='background-color: #FFFBEB; border-left: 4px solid #F59E0B; padding: 15px; border-radius: 8px; margin: 20px 0;'>" +
|
||||
"<p style='margin: 0;'><strong>URL:</strong> {{url}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Método HTTP:</strong> {{method}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Mensagem:</strong> {{mensagem}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Data/Hora:</strong> {{timestamp}}</p>" +
|
||||
'</div>' +
|
||||
"<p style='color: #6B7280; font-size: 14px; margin-top: 20px;'>" +
|
||||
'<strong>Possíveis causas:</strong><br>' +
|
||||
'• Link quebrado ou desatualizado<br>' +
|
||||
'• URL digitada incorretamente<br>' +
|
||||
'• Página movida ou removida<br>' +
|
||||
'• Tentativa de acesso a recurso inexistente' +
|
||||
'</p>' +
|
||||
"<p style='color: #6B7280; font-size: 12px; margin-top: 30px;'>" +
|
||||
'SGSE - Sistema de Gerenciamento de Secretaria - Equipe de TI' +
|
||||
'</p>' +
|
||||
'</div></body></html>',
|
||||
variaveis: [
|
||||
'destinatarioNome',
|
||||
'url',
|
||||
'method',
|
||||
'mensagem',
|
||||
'timestamp'
|
||||
],
|
||||
categoria: 'email' as const,
|
||||
tags: ['erro', '404', 'servidor', 'notificacao', 'ti']
|
||||
},
|
||||
{
|
||||
codigo: 'ERRO_SERVIDOR_500',
|
||||
nome: 'Erro 500 - Erro Interno do Servidor',
|
||||
titulo: '🚨 Erro 500 - Erro Interno do Servidor',
|
||||
corpo:
|
||||
"<html><body style='font-family: Arial, sans-serif; line-height: 1.6; color: #333;'>" +
|
||||
"<div style='max-width: 600px; margin: 0 auto; padding: 20px;'>" +
|
||||
"<h2 style='color: #DC2626;'>🚨 Erro 500 - Erro Interno do Servidor</h2>" +
|
||||
'<p>Olá <strong>{{destinatarioNome}}</strong>,</p>' +
|
||||
'<p>O sistema detectou um <strong>erro interno do servidor</strong> que requer atenção imediata:</p>' +
|
||||
"<div style='background-color: #FEF2F2; border-left: 4px solid #DC2626; padding: 15px; border-radius: 8px; margin: 20px 0;'>" +
|
||||
"<p style='margin: 0;'><strong>Código HTTP:</strong> {{statusCode}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>URL:</strong> {{url}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Método HTTP:</strong> {{method}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Mensagem:</strong> {{mensagem}}</p>" +
|
||||
"<p style='margin: 5px 0 0 0;'><strong>Data/Hora:</strong> {{timestamp}}</p>" +
|
||||
'</div>' +
|
||||
"<div style='background-color: #F9FAFB; border: 1px solid #E5E7EB; padding: 15px; border-radius: 8px; margin: 20px 0;'>" +
|
||||
"<p style='margin: 0; font-size: 12px; color: #6B7280;'><strong>Stack Trace:</strong></p>" +
|
||||
"<pre style='margin: 10px 0 0 0; padding: 10px; background-color: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 4px; font-size: 11px; white-space: pre-wrap; word-wrap: break-word; overflow-x: auto;'>{{stack}}</pre>" +
|
||||
'</div>' +
|
||||
"<p style='color: #DC2626; font-weight: bold; margin-top: 20px;'>" +
|
||||
'⚠️ AÇÃO IMEDIATA NECESSÁRIA' +
|
||||
'</p>' +
|
||||
"<p style='color: #6B7280; font-size: 12px; margin-top: 30px;'>" +
|
||||
'SGSE - Sistema de Gerenciamento de Secretaria - Equipe de TI<br>' +
|
||||
'Este é um alerta automático do sistema de monitoramento de erros.' +
|
||||
'</p>' +
|
||||
'</div></body></html>',
|
||||
variaveis: [
|
||||
'destinatarioNome',
|
||||
'statusCode',
|
||||
'url',
|
||||
'method',
|
||||
'mensagem',
|
||||
'stack',
|
||||
'timestamp'
|
||||
],
|
||||
categoria: 'email' as const,
|
||||
tags: ['erro', '500', 'servidor', 'critico', 'notificacao', 'ti']
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user