Skip to content

Instantly share code, notes, and snippets.

View akhilbojedla's full-sized avatar

Akhil Bojedla akhilbojedla

View GitHub Profile
@akhilbojedla
akhilbojedla / GlobalErrorHandler.java
Created October 11, 2019 22:42
GlobalErrorHandler to handle errors globally in Spring WebFlux
package com.bytecodehq;
import reactor.core.publisher.Mono;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
import org.springframework.context.annotation.Configuration;
@akhilbojedla
akhilbojedla / HelloController.java
Created October 11, 2019 22:38
Handle Errors using onErrorResume on Spring WebFlux Application
package com.bytecodehq.routes;
import reactor.core.publisher.Mono;
import java.io.IOException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@akhilbojedla
akhilbojedla / HelloController.java
Last active October 11, 2019 22:34
HelloController based on Spring WebFlux handling error with onErrorReturn
package com.bytecodehq.routes;
import reactor.core.publisher.Mono;
import java.io.IOException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@akhilbojedla
akhilbojedla / ErrorHandlingApplication.java
Last active October 11, 2019 22:41
Exclude defaule error handler for Spring WebFlux
package com.bytecodehq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.reactive.error.ErrorWebFluxAutoConfiguration;
@SpringBootApplication(exclude = ErrorWebFluxAutoConfiguration.class)
public class ErrorHandlingApplication {
public static void main(String[] args) {