Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Include exception information (#3077)
Browse files Browse the repository at this point in the history
  • Loading branch information
tevoinea authored May 2, 2023
1 parent 6397803 commit 16ebd2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
14 changes: 10 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ public static async Async.Task<OneFuzzResultVoid> Validate(AdoTemplate config) {
try {
connection = new VssConnection(config.BaseUrl, new VssBasicCredential(string.Empty, token.Value));
await connection.ConnectAsync();
} catch {
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, $"Failed to connect to {config.BaseUrl} using the provided token");
} catch (Exception e) {
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, new string[] {
$"Failed to connect to {config.BaseUrl} using the provided token",
$"Exception: {e}"
});
}
} else {
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_PAT, "Auth token is missing or invalid");
Expand All @@ -98,8 +101,11 @@ public static async Async.Task<OneFuzzResultVoid> Validate(AdoTemplate config) {
}
);
}
} catch {
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_FIELDS, "Failed to query and compare the valid fields for this project");
} catch (Exception e) {
return OneFuzzResultVoid.Error(ErrorCode.ADO_VALIDATION_INVALID_FIELDS, new string[] {
"Failed to query and compare the valid fields for this project",
$"Exception: {e}"
});
}

return OneFuzzResultVoid.Ok;
Expand Down
14 changes: 10 additions & 4 deletions src/ApiService/ApiService/onefuzzlib/notifications/GithubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,23 @@ public static async Async.Task<OneFuzzResultVoid> Validate(GithubIssuesTemplate
try {
gh = GetGitHubClient(auth.Value.User, auth.Value.PersonalAccessToken);
var _ = await gh.User.Get(auth.Value.User);
} catch {
return OneFuzzResultVoid.Error(ErrorCode.GITHUB_VALIDATION_INVALID_PAT, $"Failed to login to github.com with user {auth.Value.User} and the provided Personal Access Token");
} catch (Exception e) {
return OneFuzzResultVoid.Error(ErrorCode.GITHUB_VALIDATION_INVALID_PAT, new string[] {
$"Failed to login to github.com with user {auth.Value.User} and the provided Personal Access Token",
$"Exception: {e}"
});
}
} else {
return OneFuzzResultVoid.Error(ErrorCode.GITHUB_VALIDATION_INVALID_PAT, $"GithubAuth is missing or invalid");
}

try {
var _ = await gh.Repository.Get(config.Organization, config.Repository);
} catch {
return OneFuzzResultVoid.Error(ErrorCode.GITHUB_VALIDATION_INVALID_REPOSITORY, $"Failed to access repository: {config.Organization}/{config.Repository}");
} catch (Exception e) {
return OneFuzzResultVoid.Error(ErrorCode.GITHUB_VALIDATION_INVALID_REPOSITORY, new string[] {
$"Failed to access repository: {config.Organization}/{config.Repository}",
$"Exception: {e}"
});
}

return OneFuzzResultVoid.Ok;
Expand Down

0 comments on commit 16ebd2d

Please sign in to comment.