ADD improved error handling
This commit is contained in:
@@ -35,14 +35,4 @@ public class DownloadController {
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(resource);
|
||||
}
|
||||
|
||||
@ExceptionHandler(JobNotFound.class)
|
||||
public ResponseEntity<String> handleFileNotFound(JobNotFound ex) {
|
||||
return ResponseEntity.status(404).body(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(JobNotFinished.class)
|
||||
public ResponseEntity<String> handleJobNotFinished(JobNotFinished ex) {
|
||||
return ResponseEntity.status(404).body(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,4 @@ public class EditController {
|
||||
return new ResponseEntity<>(editService.getProgress(uuid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public ResponseEntity<String> handleIllegalArgument(IllegalArgumentException ex) {
|
||||
return ResponseEntity.status(404).body(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ddf.vodsystem.controllers;
|
||||
|
||||
import com.ddf.vodsystem.exceptions.JobNotFinished;
|
||||
import com.ddf.vodsystem.exceptions.JobNotFound;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public ResponseEntity<String> handleIllegalArgument(IllegalArgumentException ex) {
|
||||
return ResponseEntity.status(400).body(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(JobNotFound.class)
|
||||
public ResponseEntity<String> handleFileNotFound(JobNotFound ex) {
|
||||
return ResponseEntity.status(404).body(ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(JobNotFinished.class)
|
||||
public ResponseEntity<String> handleJobNotFinished(JobNotFinished ex) {
|
||||
return ResponseEntity.status(202).body(ex.getMessage());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user