Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!