I am not sure whether your question is about "generically handling timeouts in UI" or "generically finding out whether it is a timeout".
If it is the first one then i dont have the skills to answer that
For second, i dont think there is a "generic" way of doing that because timeouts may happen at different levels:
HTTP connection timeout.
Database query timeout
Transaction timeout
etc.
So, in order for the UI to handle it, the backend should either throw a typed exception or a proper error code(whichever model your application follows). Otherwise, UI will not be able to concretely assert whether it was a timeout or some other error.
Hope this helps