Merge captureError and captureRequestError into one function