Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda