1
- // Copyright 2023 New Relic, Inc. All rights reserved.
1
+ // Copyright 2023 New Relic, Inc. All rights reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
using System . Text ;
@@ -54,7 +54,15 @@ static async Task<int> Main(string[] args)
54
54
Console . WriteLine ( message ) ;
55
55
56
56
if ( ! options . TestMode )
57
- await CreateGhIssueAsync ( message , options . GithubToken ) ;
57
+ {
58
+ var success = await CreateGhIssueAsync ( message , options . GithubToken ) ;
59
+ if ( ! success )
60
+ {
61
+ Console . WriteLine ( "Error creating GitHub issue." ) ;
62
+ return - 1 ;
63
+ }
64
+ }
65
+
58
66
}
59
67
}
60
68
else
@@ -155,7 +163,7 @@ p.DeprecationMetadata is null // not deprecated
155
163
new PackageDeprecationInfo ( ) { PackageName = p . PackageId , PackageVersion = p . Version . ToString ( ) } ) ;
156
164
}
157
165
158
- static async Task CreateGhIssueAsync ( string message , string githubToken )
166
+ static async Task < bool > CreateGhIssueAsync ( string message , string githubToken )
159
167
{
160
168
var ghClient = new GitHubClient ( new Octokit . ProductHeaderValue ( "NugetVersionDeprecator" ) ) ;
161
169
var tokenAuth = new Credentials ( githubToken ) ;
@@ -170,9 +178,18 @@ static async Task CreateGhIssueAsync(string message, string githubToken)
170
178
newIssue . Labels . Add ( "Deprecation" ) ;
171
179
newIssue . Labels . Add ( "Nuget" ) ;
172
180
173
- var issue = await ghClient . Issue . Create ( "newrelic" , "newrelic-dotnet-agent" , newIssue ) ;
181
+ try
182
+ {
183
+ var issue = await ghClient . Issue . Create ( "newrelic" , "newrelic-dotnet-agent" , newIssue ) ;
184
+ Console . WriteLine ( $ "Created new GitHub Issue #{ issue . Number } with title { issue . Title } .") ;
185
+ return true ;
186
+ }
187
+ catch ( Exception ex )
188
+ {
189
+ Console . WriteLine ( $ "Caught exception attepting to create GitHub issue: { ex . Message } .") ;
190
+ return false ;
191
+ }
174
192
175
- Console . WriteLine ( $ "Created new GitHub Issue #{ issue . Number } with title { issue . Title } .") ;
176
193
}
177
194
178
195
static Configuration LoadConfiguration ( string path )
0 commit comments