Skip to content

Commit

Permalink
fix: Campos de erros no cliente
Browse files Browse the repository at this point in the history
  • Loading branch information
josiasdev committed Jan 26, 2025
1 parent 3156fd1 commit 7114ebc
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ public List<Clientes> buscarClientes(String token) throws Exception {
return objectMapper.readValue(response.body(), new TypeReference<List<Clientes>>() {
});
} else {
throw new Exception("Erro ao buscar clientes: " + response.body());
throw new Exception("Erro ao buscar clientes: ");
}
}

public static Clientes criarCliente(Clientes clientes, String token) throws Exception {
String clienteJson = objectMapper.writeValueAsString(clientes);
System.out.println("Sending client data: " + clienteJson);

HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(BASE_URL))
Expand All @@ -63,10 +62,10 @@ public static Clientes criarCliente(Clientes clientes, String token) throws Exce
}
} else if (response.statusCode() == 400) {
System.out.println("Erro ao criar cliente: " + response.body());
throw new Exception("Erro ao criar cliente: " + response.body());
throw new Exception("Erro ao criar cliente: ");
} else {
System.out.println("Server response: " + response.body());
throw new Exception("Erro ao criar cliente: " + response.body());
throw new Exception("Erro ao criar cliente: ");
}
}
public static Clientes editarCliente(Clientes cliente, String token) throws Exception {
Expand All @@ -88,11 +87,11 @@ public static Clientes editarCliente(Clientes cliente, String token) throws Exce
try {
return objectMapper.readValue(response.body(), Clientes.class); // Tenta converter a resposta para o objeto Cliente
} catch (IOException e) {
throw new Exception("Erro ao processar a resposta do servidor: " + e.getMessage());
throw new Exception("Erro ao processar a resposta do servidor: ");
}
}
} else {
throw new Exception("Erro ao editar cliente: " + response.body());
throw new Exception("Erro ao editar cliente: ");
}
}
public static Clientes inativarCliente(Clientes cliente, String token) throws Exception {
Expand All @@ -117,11 +116,11 @@ public static Clientes inativarCliente(Clientes cliente, String token) throws Ex
try {
return objectMapper.readValue(response.body(), Clientes.class);
} catch (IOException e) {
throw new Exception("Erro ao processar a resposta do servidor: " + e.getMessage());
throw new Exception("Erro ao processar a resposta do servidor: ");
}
}
} else {
throw new Exception("Erro ao inativar cliente: " + response.body());
throw new Exception("Erro ao inativar cliente: ");
}
}

Expand Down

0 comments on commit 7114ebc

Please sign in to comment.