Proper way to handle errors while using rest api

How do I properly handle errors returned while using rest api? for example while using login api if it returns authorization error how do I handle it properly?