MCPcopy Create free account
hub / github.com/vercel/vercel / makeDiagnosticError

Function makeDiagnosticError

packages/python/src/entrypoint.ts:373–414  ·  view source on GitHub ↗
(
  framework: string,
  diagnostics: EntrypointDiagnostics
)

Source from the content-addressed store, hash-verified

371}
372
373function makeDiagnosticError(
374 framework: string,
375 diagnostics: EntrypointDiagnostics
376): NowBuildError {
377 const code = `${framework.toUpperCase()}_ENTRYPOINT_NOT_FOUND`;
378 const link = getFrameworkEntrypointDocsUrl(framework);
379 const action = 'Learn More';
380 const displayName = getFrameworkDisplayName(framework);
381 const elsewhere = diagnostics.validCandidatesElsewhere ?? [];
382 const suggestion =
383 elsewhere.length > 0 ? renderCandidateSuggestion(elsewhere) : null;
384
385 let message: string;
386
387 if (diagnostics.existingWithoutEntrypoint.length > 0) {
388 message = getMissingExportMessage(
389 framework,
390 diagnostics.existingWithoutEntrypoint
391 );
392 if (suggestion) message += `\n\n${suggestion}`;
393 } else if (diagnostics.djangoManageBaseDir !== undefined) {
394 const where = diagnostics.djangoManageBaseDir || '.';
395 message =
396 `Found Django manage.py in "${where}" but could not resolve the application entrypoint. ` +
397 `Ensure WSGI_APPLICATION or ASGI_APPLICATION is set in your Django settings.`;
398 if (suggestion) message += `\n\n${suggestion}`;
399 } else if (
400 diagnostics.pyprojectAppScript &&
401 diagnostics.pyprojectCheckedPaths?.length
402 ) {
403 const checked = diagnostics.pyprojectCheckedPaths.join(' or ');
404 message = `pyproject.toml [project.scripts] defines app = "${diagnostics.pyprojectAppScript}" but ${checked} was not found.`;
405 if (suggestion) message += `\n\n${suggestion}`;
406 } else if (suggestion) {
407 message = `No ${displayName} entrypoint found in default locations, ${suggestion}`;
408 } else {
409 const searchedList = PYTHON_CANDIDATE_ENTRYPOINTS.join(', ');
410 message = `No ${displayName} entrypoint found. Set "tool.vercel.entrypoint" in pyproject.toml or define an entrypoint in one of: ${searchedList}.`;
411 }
412
413 return new NowBuildError({ code, message, link, action });
414}
415
416/**
417 * Detect a Python entrypoint for any Python framework using AST-based detection.

Callers 1

detectPythonEntrypointFunction · 0.85

Calls 5

getFrameworkDisplayNameFunction · 0.85
getMissingExportMessageFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected