Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
Axios statusText is always empty

I've been using axios recently but I can't get the error message thrown by Spring Boot RuntimeException.

I've created a simple RuntimeException which throws 404 status:

@ResponseStatus(HttpStatus.BAD_REQUEST)
public class BadRequestException extends RuntimeException {
    public BadRequestException(String message) {
        super(message);
    }
}

I make a GET request to one of my endpoint where all it does is throw the BadRequestException with some message:

@RestController
public class TestController {

    @GetMapping("/throw")
    public ResponseEntity<?> throwError() {
        throw new BadRequestException("This text should be in statusText");
    }
}

console.log() from the catch clause (.catch((error) => console.log(error.response))) is: enter image description here

As you can see, the statusText is just an empty string, where "This text should be in statusText" should be expected.

Using fetch() works perfectly fine, but switching from axios to fetch in my situation will be time-wasting.

Am I missing something? Do I even throw the exceptions with my messages correctly?

Thanks in advance for all answers!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda