"Expected an error object to be thrown." At From 0 to Production - The Modern React Tutorial
Hi, I was watching Theo's "From 0 to Production - The Modern React Tutorial (RSCs, Next.js, Shadui, Drizzle, TS and more)" and at 55:35, he was implementing UploadThing to the app and I had an error at
if (!user.userId) throw new UploadThingError("Unauthorized");
and I couldn't fix it. I am using VSCode's ESLint Plugin and it gave me this error.
"Expected an error object to be thrown."
I have no idea how to fix it. Can anyone help me?
Thanks a lot!
3 Replies
I have the same issue
Same issue. I assumed UploadThingError extends an Error object, but that appears to be inocrrect.
The "simple" solution is to just throw a regular Error object.
I'm not really familair with the tutorial (yet) but you could try to pass "as Error" at the end of the line 17