How to handle RTK query errors in getServerSideProps?

I passed a slug that was not in database through url and it threw me this error which i don’t know how to handle.

[![Error Message thrown by RTK Query]
enter image description here

Here is my getServerSideProps logic.
getServerSideProps Logic