UNPKG

wrap-git

Version:

Wraps GitHub profile and provides summarized details about repos, commits and language coverages for a given profile.

19 lines (18 loc) 899 B
import GitWrapperError from "../model/GitWrapperError.js"; export const throwGitError = (status, error) => { switch (status) { case 401: throw new GitWrapperError("UNAUTHORIZED", "Invalid token or unauthorized access", error); case 403: throw new GitWrapperError("RATE_LIMIT_EXCEEDED", "Rate limit exceeded. Please wait before making more requests.", error); case 404: throw new GitWrapperError("NOT_FOUND", "The requested resource was not found", error); default: throw new GitWrapperError("GITHUB_API_ERROR", "An error occurred while interacting with the GitHub API", error); } }; export const throwError = (err) => { if (err instanceof GitWrapperError) throw err; throw new GitWrapperError("NETWORK_ERROR", "A network error occurred. Please check your internet connection.", err.message); };