Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Add another try/catch in. Probably wont do anything
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Warner committed Oct 11, 2017
1 parent efc5580 commit a74aedc
Showing 1 changed file with 48 additions and 40 deletions.
88 changes: 48 additions & 40 deletions Matterhook.NET/Webhooks/Github/GithubHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,57 @@ public class GithubHook

public GithubHook(StringValues strEvent, StringValues signature, StringValues delivery, string payloadText)
{
Event = strEvent;
Signature = signature;
Delivery = delivery;
PayloadString = payloadText;
try
{
Event = strEvent;
Signature = signature;
Delivery = delivery;
PayloadString = payloadText;

switch (Event)
switch (Event)
{
case "pull_request":
Payload = JsonConvert.DeserializeObject<PullRequestEvent>(PayloadString);
break;
case "issues":
Payload = JsonConvert.DeserializeObject<IssuesEvent>(PayloadString);
break;
case "issue_comment":
Payload = JsonConvert.DeserializeObject<IssueCommentEvent>(PayloadString);
break;
case "repository":
Payload = JsonConvert.DeserializeObject<RepositoryEvent>(PayloadString);
break;
case "create":
Payload = JsonConvert.DeserializeObject<CreateEvent>(PayloadString);
break;
case "delete":
Payload = JsonConvert.DeserializeObject<DeleteEvent>(PayloadString);
break;
case "pull_request_review":
Payload = JsonConvert.DeserializeObject<PullRequestReviewEvent>(PayloadString);
break;
case "pull_request_review_comment":
Payload = JsonConvert.DeserializeObject<PullRequestReviewCommentEvent>(PayloadString);
break;
case "push":
Payload = JsonConvert.DeserializeObject<PushEvent>(PayloadString);
break;
case "commit_comment":
Payload = JsonConvert.DeserializeObject<CommitCommentEvent>(PayloadString);
break;
case "status":
Payload = JsonConvert.DeserializeObject<StatusEvent>(PayloadString);
break;
default:
throw new Exception($"Unhandled Event Type: {Event}");
}
}
catch (Exception e)
{
case "pull_request":
Payload = JsonConvert.DeserializeObject<PullRequestEvent>(PayloadString);
break;
case "issues":
Payload = JsonConvert.DeserializeObject<IssuesEvent>(PayloadString);
break;
case "issue_comment":
Payload = JsonConvert.DeserializeObject<IssueCommentEvent>(PayloadString);
break;
case "repository":
Payload = JsonConvert.DeserializeObject<RepositoryEvent>(PayloadString);
break;
case "create":
Payload = JsonConvert.DeserializeObject<CreateEvent>(PayloadString);
break;
case "delete":
Payload = JsonConvert.DeserializeObject<DeleteEvent>(PayloadString);
break;
case "pull_request_review":
Payload = JsonConvert.DeserializeObject<PullRequestReviewEvent>(PayloadString);
break;
case "pull_request_review_comment":
Payload = JsonConvert.DeserializeObject<PullRequestReviewCommentEvent>(PayloadString);
break;
case "push":
Payload = JsonConvert.DeserializeObject<PushEvent>(PayloadString);
break;
case "commit_comment":
Payload = JsonConvert.DeserializeObject<CommitCommentEvent>(PayloadString);
break;
case "status":
Payload = JsonConvert.DeserializeObject<StatusEvent>(PayloadString);
break;
default:
throw new Exception($"Unhandled Event Type: {Event}");
throw new Exception($"Problem Converting payload: {e.Message}");
}

}

public string Event { get; set; }
Expand Down

0 comments on commit a74aedc

Please sign in to comment.