Skip to content

Commit

Permalink
remove throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Nov 29, 2023
1 parent 9e36e45 commit 504cb84
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions api/controllers/v1/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { RepoBranchesRepository } from '../../../src/repositories/repoBranchesRe
import { markBuildArtifactsForDeletion, validateJsonWebhook } from '../../handlers/github';
import { DocsetsRepository } from '../../../src/repositories/docsetsRepository';
import { ReposBranchesDocsetsDocument } from '../../../modules/persistence/src/services/metadata/repos_branches';
import { PushEvent } from '@octokit/webhooks-types';

async function prepGithubPushPayload(
githubEvent: any,

Check warning on line 12 in api/controllers/v1/github.ts

View workflow job for this annotation

GitHub Actions / test

Unexpected any. Specify a different type
Expand Down Expand Up @@ -87,9 +88,17 @@ export const TriggerBuild = async (event: any = {}, context: any = {}): Promise<
};
}

throw new Error(`event body? => ${JSON.stringify(event.body)}`);

const body = JSON.parse(event.body);
let body: PushEvent;
try {
body = JSON.parse(event.body) as PushEvent;
} catch (e) {
console.log('[TriggerBuild]: ERROR! Could not parse event.body', e);
return {
statusCode: 502,
headers: { 'Content-Type': 'text/plain' },
body: ' ERROR! Could not parse event.body',
};
}

if (body.deleted) {
return {
Expand Down
1 change: 0 additions & 1 deletion src/services/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IConfig } from 'config';
import { InvalidJobError } from '../errors/errors';
import { IFileSystemServices } from './fileServices';
import simpleGit, { SimpleGit } from 'simple-git';
import { getDirectory } from '../job/jobHandler';
const git: SimpleGit = simpleGit();

export interface IRepoConnector {
Expand Down

0 comments on commit 504cb84

Please sign in to comment.