#1664·wasp

Improve error messages reported by the framework code

Author: MartinsosCreated Jan 23, 2024Updated Sep 30, 2026
Labelsenhancementrestructuringregression

[!IMPORTANT] by @sodic

This issue explores improving code integration error messages (errors we get in places where framework code integrates with the user code). The other kind of error messages the framework code might report (errors in user code detected while building the framework code) are explored in #2247.

Related:

Right now, after restructuring, there are quite some error messages that are not easy to decifer. Not that it was perfect before, but some of them seem to have worsened (while maybe some other have improved?). Let's track some of them down here so we can look into fixing it.

If in Wasp we import JS path that doesn't exist, we get message from [ Server ] that is not very clear. For example, for

apiNamespace fooBarNamespace {
  middlewareConfigFn: import { fooBarNamespace } from "@src/foo.js",
  path: "/foo/bar"
}

if foo.js doesn't exist, we get

[ Server ] src/routes/apis/index.ts(8,84): error TS2307: Cannot find module '../../../../../../src/foo.js' or its corresponding type declarations.

It is not clear at all from this what the cause of that error is, what is the source, where is that path wrongly used. It is not even very clear that that path is leading to this file belonging to user.

Similarly, this is what we get if foo.js exists but doesn't export { fooBarNamespace }:

[ Server ] src/routes/apis/index.ts(8,10): error TS2305: Module '"../../../../../../src/foo.js"' has no exported member 'fooBarNamespace'.