Skip to content
Snippets Groups Projects
Commit 3a05fc70 authored by Cody Dumortier's avatar Cody Dumortier
Browse files

Gérer les erreurs

parent 6001e98c
No related branches found
No related tags found
No related merge requests found
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
......
......@@ -16,7 +16,7 @@ import java.util.logging.Logger;
*/
public class Main {
// Base URI the Grizzly HTTP server will listen on
public static final String BASE_URI = "http://localhost:8080/myapp/";
public static final String BASE_URI = "http://localhost:8080/api/v1";
/**
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this application.
......
package fr.ulille.iut.tva.ressource;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
public class NiveauTvaInexistantException extends WebApplicationException {
private static final long serialVersionUID = 939875418210403804L;
public NiveauTvaInexistantException() {
super(Response.status(Response.Status.NOT_ACCEPTABLE).entity("Niveau de TVA inexistant").build());
}
......@@ -6,7 +6,29 @@ import fr.ulille.iut.tva.service.TauxTva;
/**
* TvaRessource
*/
@Path("tva")
public class TvaRessource {
private CalculTva calculTva = new CalculTva();
@GET
@PATH("valeur/{niveauTVA}")
public double getValeurTauxParDefaut(@PathParam("niveauTVA") String niveau) {
try {
return TauxTva.valueOf((niveau.toUpperCase())).taux;
}
catch(Exception e) {
throw new NiveauTvaInexistantException();
}
}
@GET
@PATH("reduit?{somme}")
public double getMontantTotal(@PathParam("somme") double somme) {
try {
return TauxTva.REDUIT.taux * somme;
}
catch (Exception e){
throw new NiveauTvaInexistantException();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment