When I started programming I had a problem trying to overcheck everything, all the errors, and everything. These days I discovered something similar:
(typeof err === 'object' && err.status==403) || (typeof err === 'string' && err.substring(0, 15) === 'Not authorized')
Firstly why the back-end sends either a string or an object.
Secondly 'Not authorized' has only 14 characters, which means the second condition still fails if we suppose that the error thrown by the server starts with
Remember, this is a series with scary code, so if you wanna see the complete list, you can do it here.