diff --git a/plugins/techdocs-backend/src/techdocs/stages/publish/local.ts b/plugins/techdocs-backend/src/techdocs/stages/publish/local.ts
index 07cef2f4d2..464c4b90a0 100644
--- a/plugins/techdocs-backend/src/techdocs/stages/publish/local.ts
+++ b/plugins/techdocs-backend/src/techdocs/stages/publish/local.ts
@@ -53,9 +53,7 @@ export class LocalPublish implements PublisherBase {
);
if (!fs.existsSync(publishDir)) {
- this.logger.info(
- `[TechDocs]: Could not find ${publishDir}, creates the directory.`,
- );
+ this.logger.info(`Could not find ${publishDir}, creating the directory.`);
fs.mkdirSync(publishDir, { recursive: true });
}
@@ -63,7 +61,7 @@ export class LocalPublish implements PublisherBase {
fs.copy(directory, publishDir, err => {
if (err) {
this.logger.debug(
- `[TechDocs]: Failed to copy docs from ${directory} to ${publishDir}`,
+ `Failed to copy docs from ${directory} to ${publishDir}`,
);
reject(err);
}
diff --git a/plugins/techdocs/src/api.ts b/plugins/techdocs/src/api.ts
index 194ad14d30..7281ebdf13 100644
--- a/plugins/techdocs/src/api.ts
+++ b/plugins/techdocs/src/api.ts
@@ -95,7 +95,13 @@ export class TechDocsStorageApi implements TechDocsStorage {
);
if (request.status === 404) {
- throw new Error('Page not found');
+ let errorMessage = 'Page not found. ';
+ // path is empty for the home page of an entity's docs site
+ if (!path) {
+ errorMessage +=
+ 'This could be because there is no index.md file in the root of the docs directory of this repository.';
+ }
+ throw new Error(errorMessage);
}
return request.text();
diff --git a/plugins/techdocs/src/reader/components/Reader.tsx b/plugins/techdocs/src/reader/components/Reader.tsx
index 785c6f1c6b..fe3a34564c 100644
--- a/plugins/techdocs/src/reader/components/Reader.tsx
+++ b/plugins/techdocs/src/reader/components/Reader.tsx
@@ -153,7 +153,7 @@ export const Reader = ({ entityId, onReady }: Props) => {
]);
if (error) {
- return ;
+ return ;
}
return (
diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx
index 7b0ec80619..d3c98fec78 100644
--- a/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx
+++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.test.tsx
@@ -27,3 +27,17 @@ describe('', () => {
expect(rendered.getByTestId('go-back-link')).toBeDefined();
});
});
+
+describe('', () => {
+ it('should render with status code, custom error message and go back link', () => {
+ const rendered = render(
+ wrapInTestApp(
+ ,
+ ),
+ );
+ rendered.getByText(/This is a custom error message/i);
+ rendered.getByText(/404/i);
+ rendered.getByText(/Looks like someone dropped the mic!/i);
+ expect(rendered.getByTestId('go-back-link')).toBeDefined();
+ });
+});
diff --git a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx
index c774000bd5..744242e343 100644
--- a/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx
+++ b/plugins/techdocs/src/reader/components/TechDocsNotFound.tsx
@@ -17,11 +17,15 @@
import React from 'react';
import { ErrorPage } from '@backstage/core';
-export const TechDocsNotFound = () => {
+type Props = {
+ errorMessage?: string;
+};
+
+export const TechDocsNotFound = ({ errorMessage }: Props) => {
return (
);