Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit adecd0e

Browse files
authored
Merge pull request anomalyco#616 from serverless-stack/bug-sst-start-handler-not-found-copy
sst start: print descriptive error message for handler not found
2 parents c01f49d + 51c9f04 commit adecd0e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/cli/scripts/start.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,15 +690,18 @@ function handleRunTypeCheck(srcPath, inputFiles, tsconfig, config) {
690690

691691
async function getHandlerFilePath(appPath, srcPath, handler) {
692692
// Check entry path exists
693-
let entryPath = "";
693+
let entryPath;
694694
const entryPathExists = [".ts", ".tsx", ".js", ".jsx"].some((ext) => {
695695
entryPath = path.join(appPath, srcPath, addExtensionToHandler(handler, ext));
696696
return fs.existsSync(entryPath);
697697
});
698698

699+
// Print out the error message and throw
699700
if (!entryPathExists) {
700701
const handlerPosixPath = getHandlerFullPosixPath(srcPath, handler);
701-
throw new Error(`Cannot find a handler file for "${handlerPosixPath}".`);
702+
const errorMessage = `Cannot find a handler file for "${handlerPosixPath}"`;
703+
logger.error(`${chalk.red("error")} ${errorMessage}\n`);
704+
throw new Error(errorMessage);
702705
}
703706

704707
return entryPath;

0 commit comments

Comments
 (0)