Read this helpful article on handling exceptions correctly for peace of mind and to benefit your colleagues. Not only make you happy but also your colleagues.
A story about how I tried to solve an architectural error with minimal code changes and what problems sometimes occur in popular libraries. So, let's go!
I think it's a matter of taste what status to give an exception. In any case, this is a contract that you will write in confluence or swagger, what status your endpoint can return and what message codes can be received. On those projects where I work, there are old and new services with different practices. as for me personally, I prefer to use status 400. I hope I understand you correctly.
How often do good names appear in examples? Besides, it's a matter of taste.
How the response is handled depends on how you invoke the requests. When I make a service and I know that it will be accessed by many different systems, then I simplify the work for everyone and make easy connector using Retrofit, and in case of a successful response, I simply return its body, otherwise I handle an exception for the calling service.
If the call is made by the ETL system, then the processing is about the same or even more convenient, because you can visually make different flows depending on the status and exception code that the service returned. To answer this question, you can write a whole article with examples. Judging by your place of work, I hope you know how to intercept not only status 200.
Comments
Nov 16, 2023 · Artem Artemev
Thank you!
Aug 10, 2023 · Artem Artemev
I think it's a matter of taste what status to give an exception. In any case, this is a contract that you will write in confluence or swagger, what status your endpoint can return and what message codes can be received. On those projects where I work, there are old and new services with different practices. as for me personally, I prefer to use status 400. I hope I understand you correctly.
Aug 10, 2023 · Artem Artemev
How often do good names appear in examples? Besides, it's a matter of taste.
How the response is handled depends on how you invoke the requests. When I make a service and I know that it will be accessed by many different systems, then I simplify the work for everyone and make easy connector using Retrofit, and in case of a successful response, I simply return its body, otherwise I handle an exception for the calling service.
If the call is made by the ETL system, then the processing is about the same or even more convenient, because you can visually make different flows depending on the status and exception code that the service returned. To answer this question, you can write a whole article with examples. Judging by your place of work, I hope you know how to intercept not only status 200.