Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save enzobonggio/8807cfc7e63c73c38fad9018a5c76702 to your computer and use it in GitHub Desktop.
Save enzobonggio/8807cfc7e63c73c38fad9018a5c76702 to your computer and use it in GitHub Desktop.
@SpringBootApplication
@RestController
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@GetMapping("/something")
Mono<Void> something() {
return Mono.error(new Throwable("mensaje"));
}
}
@ControllerAdvice
public class ExHandler {
@ExceptionHandler(Throwable.class)
@ResponseBody
Complex handleAll(Throwable ex) {
return new Complex();
}
@Data
public static class Complex {
String something;
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-webflux')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('io.projectreactor:reactor-test')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment