Introduce the @backstage/errors package.

Encode thrown errors in the backend as a JSON payload using a facility in that package, and render helpful frontend displays of those errors.

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-03-08 17:02:51 +01:00
parent 9804a5273e
commit 8686eb38cf
85 changed files with 880 additions and 177 deletions
+1
View File
@@ -33,6 +33,7 @@
"@backstage/catalog-client": "^0.3.7",
"@backstage/catalog-model": "^0.7.4",
"@backstage/config": "^0.1.3",
"@backstage/errors": "^0.1.1",
"@backstage/integration": "^0.5.1",
"@gitbeaker/core": "^28.0.2",
"@gitbeaker/node": "^28.0.2",
@@ -19,7 +19,7 @@ import {
TemplateEntityV1beta2,
} from '@backstage/catalog-model';
import { CatalogApi } from '@backstage/catalog-client';
import { ConflictError, NotFoundError } from '@backstage/backend-common';
import { ConflictError, NotFoundError } from '@backstage/errors';
/**
* A catalog client tailored for reading out entity data from the catalog.
@@ -15,7 +15,7 @@
*/
import { InputBase, TemplateAction } from './types';
import { ConflictError, NotFoundError } from '@backstage/backend-common';
import { ConflictError, NotFoundError } from '@backstage/errors';
export class TemplateActionRegistry {
private readonly actions = new Map<string, TemplateAction<any>>();
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrations } from '@backstage/integration';
import { CatalogApi } from '@backstage/catalog-client';
import { getEntityName } from '@backstage/catalog-model';
@@ -17,7 +17,8 @@
import fs from 'fs-extra';
import { resolve as resolvePath } from 'path';
import Docker from 'dockerode';
import { InputError, UrlReader } from '@backstage/backend-common';
import { UrlReader } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrations } from '@backstage/integration';
import { JsonObject } from '@backstage/config';
import { TemplaterBuilder, TemplaterValues } from '../../../stages/templater';
@@ -16,7 +16,8 @@
import fs from 'fs-extra';
import { resolve as resolvePath, isAbsolute } from 'path';
import { InputError, UrlReader } from '@backstage/backend-common';
import { UrlReader } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrations } from '@backstage/integration';
import { JsonValue } from '@backstage/config';
@@ -15,7 +15,8 @@
*/
import path from 'path';
import { InputError, UrlReader } from '@backstage/backend-common';
import { UrlReader } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrations } from '@backstage/integration';
import { fetchContents } from './helpers';
import { createTemplateAction } from '../../createTemplateAction';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrationRegistry } from '@backstage/integration';
import { initRepoAndPush } from '../../../stages/publish/helpers';
import { GitRepositoryCreateOptions } from 'azure-devops-node-api/interfaces/GitInterfaces';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import {
BitbucketIntegrationConfig,
ScmIntegrationRegistry,
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import {
GithubCredentialsProvider,
ScmIntegrationRegistry,
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { ScmIntegrationRegistry } from '@backstage/integration';
import { Gitlab } from '@gitbeaker/node';
import { initRepoAndPush } from '../../../stages/publish/helpers';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
export const parseRepoUrl = (repoUrl: string) => {
let parsed;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import {
LOCATION_ANNOTATION,
parseLocationReference,
@@ -16,7 +16,7 @@
import fs from 'fs-extra';
import path from 'path';
import { fileURLToPath } from 'url';
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { PreparerBase, PreparerOptions } from './types';
export class FilePreparer implements PreparerBase {
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
import { spawn } from 'child_process';
import { PassThrough, Writable } from 'stream';
@@ -15,11 +15,8 @@
*/
import { JsonObject } from '@backstage/config';
import {
ConflictError,
NotFoundError,
resolvePackagePath,
} from '@backstage/backend-common';
import { resolvePackagePath } from '@backstage/backend-common';
import { ConflictError, NotFoundError } from '@backstage/errors';
import { Knex } from 'knex';
import { v4 as uuid } from 'uuid';
import {
@@ -24,7 +24,7 @@ import fs from 'fs-extra';
import path from 'path';
import { TemplateActionRegistry } from '../actions/TemplateActionRegistry';
import * as handlebars from 'handlebars';
import { InputError } from '@backstage/backend-common';
import { InputError } from '@backstage/errors';
type Options = {
logger: Logger;
@@ -42,12 +42,8 @@ import { templateEntityToSpec } from '../scaffolder/tasks/TemplateConverter';
import { TemplateActionRegistry } from '../scaffolder/actions/TemplateActionRegistry';
import { createLegacyActions } from '../scaffolder/stages/legacy';
import { getEntityBaseUrl, getWorkingDirectory } from './helpers';
import {
InputError,
NotFoundError,
PluginDatabaseManager,
UrlReader,
} from '@backstage/backend-common';
import { PluginDatabaseManager, UrlReader } from '@backstage/backend-common';
import { InputError, NotFoundError } from '@backstage/errors';
import { CatalogApi } from '@backstage/catalog-client';
import {
TemplateEntityV1alpha1,