build
This commit is contained in:
parent
dae11465e9
commit
cd3d686ecb
6 changed files with 38 additions and 19 deletions
|
|
@ -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"}`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue