File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed
app/services/discord/modules Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -201,20 +201,35 @@ export default async (bot: DiscordBot): Promise<void> => {
201201 / h t t p s ? : \/ \/ g i t h u b \. c o m \/ (?< owner > \S + ) \/ (?< repo > \S + ) \/ (?< sha > \S + ) / . exec (
202202 url ?? ""
203203 ) || [ ] ;
204-
205- const res = await (
206- await bot . container . getService ( "Github" )
207- ) . octokit . rest . repos . getCommit ( { owner, repo, ref } ) ;
208- files = res . data . files ?. flatMap ( f => f . filename ) ;
204+ try {
205+ const res = await (
206+ await bot . container . getService ( "Github" )
207+ ) . octokit . rest . repos . getCommit ( { owner, repo, ref } ) ;
208+ files = res . data . files ?. flatMap ( f => f . filename ) ;
209+ } catch ( err ) {
210+ await ctx . reply (
211+ "something went wrong fetching the files from github :( ... aborting"
212+ ) ;
213+ console . error ( err ) ;
214+ return ;
215+ }
209216 } else if ( url . startsWith ( "https://gitlab.com" ) ) {
210217 const [ , id , sha ] =
211218 / h t t p s ? : \/ \/ g i t l a b \. c o m \/ (?< id > \S + ) \/ - \/ c o m m i t \/ (?< sha > \S + ) / . exec (
212219 url ?? ""
213220 ) || [ ] ;
214- const res = await (
215- await bot . container . getService ( "Gitlab" )
216- ) . api . Commits . showDiff ( encodeURIComponent ( id ) , sha ) ;
217- files = res . filter ( f => ! f . deleted_file ) . flatMap ( f => f . new_path ) ;
221+ try {
222+ const res = await (
223+ await bot . container . getService ( "Gitlab" )
224+ ) . api . Commits . showDiff ( encodeURIComponent ( id ) , sha ) ;
225+ files = res . filter ( f => ! f . deleted_file ) . flatMap ( f => f . new_path ) ;
226+ } catch ( err ) {
227+ await ctx . reply (
228+ "something went wrong fetching the files from gitlab :( ... aborting"
229+ ) ;
230+ console . error ( err ) ;
231+ return ;
232+ }
218233 }
219234
220235 if ( ! files || files . length === 0 ) {
You can’t perform that action at this time.
0 commit comments