public static boolean isUnauthorized(final Exception e) {
        String message = null;
        if (e instanceof IOException) {
            message = e.getMessage();
        }
        final Throwable cause = e.getCause();
        if (cause instanceof IOException) {
            String causeMessage = cause.getMessage();
            if (!TextUtils.isEmpty(causeMessage)) {
                message = causeMessage;
            }
        }

        if (TextUtils.isEmpty(message)) {
            return false;
        }

        if ("Received authentication challenge is null".equals(message)) {
            return true;
        }
        return "No authentication challenges found".equals(message);

    }
Is the given {@link Exception} due to a 401 Unauthorized API response?

@param e
@return true if 401, false otherwise
app/src/main/java/com/github/pockethub/android/accounts/AccountUtils.java