0% found this document useful (0 votes)
1 views

exception

Uploaded by

ratovolova
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

exception

Uploaded by

ratovolova
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.simplon.dvdstore.

exceptions;

import lombok.Getter;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.server.ResponseStatusException;

@ResponseStatus(code = HttpStatus.NOT_FOUND, reason = "Dvd Not Found")


@Getter

public class DvdNotFoundException extends ResponseStatusException {

public DvdNotFoundException(HttpStatus status){


super(status);
}

public DvdNotFoundException(HttpStatus status, String reason){


super(status,reason);
}
public DvdNotFoundException(HttpStatus status, String reason, Throwable cause){
super(status, reason, cause);
}

**************************************************ajout****************************
*********************
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.server.ResponseStatusException;

@ResponseStatus(code = HttpStatus.BAD_REQUEST, reason = "Error Adding DVD")


public class DvdAddException extends ResponseStatusException {

public DvdAddException(HttpStatus status) {


super(status);
}

public DvdAddException(HttpStatus status, String reason) {


super(status, reason);
}

public DvdAddException(HttpStatus status, String reason, Throwable cause) {


super(status, reason, cause);
}
}
***************************************************ajout***************************
*************
import org.springframework.stereotype.Service;

@Service
public class DvdService {

public void addDvd(Dvd dvd) {


// Logique d'ajout du DVD ici
boolean ajoutReussi = false; // Exemple : Indique si l'ajout a réussi

if (!ajoutReussi) {
// En cas d'erreur d'ajout, générez une DvdAddException
throw new DvdAddException(HttpStatus.BAD_REQUEST, "Erreur lors de
l'ajout du DVD");
}
}
}

You might also like