exceptions

This commit is contained in:
dasha 2023-04-09 18:46:22 +04:00
parent 6f5a9771f0
commit cf01392e65
3 changed files with 2983 additions and 1 deletions

2976
front/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,7 @@ public class OrderRepositoryImpl implements OrderRepositoryExtension {
currentOrder.addSession(orderSession); currentOrder.addSession(orderSession);
currentSession.addOrder(orderSession); currentSession.addOrder(orderSession);
currentSession.setCapacity(currentSession.getCapacity() - count); currentSession.setCapacity(currentSession.getCapacity() - count);
em.merge(orderSession);
em.merge(currentSession); em.merge(currentSession);
em.merge(currentOrder); em.merge(currentOrder);
return orderRepository.findById(id); return orderRepository.findById(id);

View File

@ -1,7 +1,9 @@
package com.labwork1.app.util.error; package com.labwork1.app.util.error;
import com.labwork1.app.student.service.CinemaNotFoundException;
import com.labwork1.app.student.service.CustomerNotFoundException; import com.labwork1.app.student.service.CustomerNotFoundException;
import com.labwork1.app.student.service.OrderNotFoundException; import com.labwork1.app.student.service.OrderNotFoundException;
import com.labwork1.app.student.service.SessionNotFoundException;
import com.labwork1.app.util.validation.ValidationException; import com.labwork1.app.util.validation.ValidationException;
import org.springframework.context.support.DefaultMessageSourceResolvable; import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -17,7 +19,10 @@ public class AdviceController {
@ExceptionHandler({ @ExceptionHandler({
CustomerNotFoundException.class, CustomerNotFoundException.class,
OrderNotFoundException.class, OrderNotFoundException.class,
ValidationException.class SessionNotFoundException.class,
CinemaNotFoundException.class,
ValidationException.class,
IllegalArgumentException.class
}) })
public ResponseEntity<Object> handleException(Throwable e) { public ResponseEntity<Object> handleException(Throwable e) {
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);