Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prefix error messages with "[@octokit/webhooks] " #339

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Webhooks<T extends WebhookEvent = WebhookEvent, U = {}> {

constructor(options?: Options<T>) {
if (!options || !options.secret) {
throw new Error("options.secret required");
throw new Error("[@octokit/webhooks] options.secret required");
}

const state: State = {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Options, State } from "../types";

export function createMiddleware(options: Options<any>) {
if (!options || !options.secret) {
throw new Error("options.secret required");
throw new Error("[@octokit/webhooks] options.secret required");
}

const state: State = {
Expand Down
4 changes: 3 additions & 1 deletion src/middleware/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function middleware(

const missingHeaders = getMissingHeaders(request).join(", ");
if (missingHeaders) {
const error = new Error(`Required headers missing: ${missingHeaders}`);
const error = new Error(
`[@octokit/webhooks] Required headers missing: ${missingHeaders}`
);

return state.eventHandler.receive(error).catch(() => {
response.statusCode = 400;
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/verify-and-receive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function verifyAndReceive(

if (!matchesSignature) {
const error = new Error(
"signature does not match event payload and secret"
"[@octokit/webhooks] signature does not match event payload and secret"
);

return state.eventHandler.receive(
Expand Down
4 changes: 3 additions & 1 deletion src/verify/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export function verify(
signature?: string
): boolean {
if (!secret || !eventPayload || !signature) {
throw new TypeError("secret, eventPayload & signature required");
throw new TypeError(
"[@octokit/webhooks] secret, eventPayload & signature required"
);
}

const signatureBuffer = Buffer.from(signature);
Expand Down