I have an Angular 9 project that works with a .NET Core WEB API. The site features user authentication that is role based. The API returns two types of errors: 401 and 403 depending on the authorization rules for a controller method.
My goal is to display a message in my layout component when the API returns any of these errors, for example:
- 401: 'Session has expired, please log in.'
- 403: 'You do not have access to this feature.'
Is there any way to catch these errors in Angular and know which one was thrown?