This commit is contained in:
Luiz H. R. Silva 2024-06-27 11:32:54 -03:00
parent dae11465e9
commit cd3d686ecb
6 changed files with 38 additions and 19 deletions

View file

@ -32,8 +32,15 @@ export type tipoRespostaErro = {
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro
export const gerarRespostas = <T>(
registrarErroInterno: (erro: T) => Partial<tipoRespostaErro>,
export const gerarRespostas = (
/** Faz um processamento quando erro interno
* Recebe o erro gerado, mensagem personalizada e detalhes
*/
registrarErroInterno: (
erro: any,
mensagem?: string,
detalhes?: string[],
) => Partial<tipoRespostaErro>,
) => {
const valor = <T>(valor: T, detalhes?: string[]): tipoRespostaSucesso<T> => {
return {
@ -98,8 +105,12 @@ export const gerarRespostas = <T>(
}
}
const erroInterno = (parametros: T, mensagem?: string): tipoRespostaErro => {
const resRegistro = registrarErroInterno(parametros)
const erroInterno = (
erro: any,
mensagem?: string,
detalhes?: string[],
): tipoRespostaErro => {
const resRegistro = registrarErroInterno(erro, mensagem, detalhes)
const mensagemFim = `${mensagem || "Erro interno"}`