This commit is contained in:
Luiz Silva 2024-08-11 12:11:08 -03:00
parent 8e46650e69
commit 42de15ba86
4 changed files with 20 additions and 36 deletions

View file

@ -32,16 +32,18 @@ export type tipoRespostaErro = {
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro
export type tipoPrErroInterno = {
erro: any
mensagem?: string
local: string
__filename?: string
}
export const gerarRespostas = (
/** Faz um processamento quando erro interno
* Recebe o erro gerado, mensagem personalizada e detalhes
*/
registrarErroInterno: (op: {
erro: any
mensagem?: string
local: string
__filename?: string
}) => Partial<tipoRespostaErro>,
registrarErroInterno: (op: tipoPrErroInterno) => Partial<tipoRespostaErro>,
) => {
const valor = <T>(valor: T, detalhes?: string[]): tipoRespostaSucesso<T> => {
return {
@ -106,11 +108,7 @@ export const gerarRespostas = (
}
}
const erroInterno = (op: {
erro: any
mensagem?: string
local: string
}): tipoRespostaErro => {
const erroInterno = (op: tipoPrErroInterno): tipoRespostaErro => {
const resRegistro = registrarErroInterno(op)
const mensagemFim = `${op.mensagem || "Erro interno"}`