add error handling

This commit is contained in:
Namrata Jha
2021-12-22 15:30:35 +00:00
committed by GitHub
parent 324039ba0a
commit 372546727d
2 changed files with 12 additions and 0 deletions

4
dist/index.js vendored
View File

@@ -206,6 +206,10 @@ function getRateLimit(token) {
headers: {
Accept: 'application/vnd.github.package-deletes-preview+json'
}
})).pipe(operators_1.catchError(err => {
return rxjs_1.throwError(err.errors && err.errors.length > 0
? `${err.errors[0].message}`
: `unknown error`);
}));
}
exports.getRateLimit = getRateLimit;

View File

@@ -52,6 +52,14 @@ export function getRateLimit(token: string): Observable<RateLimitResponse> {
Accept: 'application/vnd.github.package-deletes-preview+json'
}
}) as Promise<RateLimitResponse>
).pipe(
catchError(err => {
return throwError(
err.errors && err.errors.length > 0
? `${err.errors[0].message}`
: `unknown error`
)
})
)
}