Learn R Programming

IssueTrackeR (version 1.4.1)

github_errors: GitHub API Error Handling Utilities

Description

A collection of functions to detect GitHub API errors and generate user-friendly error messages.

Usage

has_timeout(msg)

need_auth(msg)

api_rate_reached(msg)

has_no_http(msg)

is_not_found(msg)

is_orgs_call(msg)

is_user_call(msg)

is_repo_call(msg)

wrong_repo_msg(owner, repo)

wrong_username_msg(owner)

wrong_org_name_msg(owner)

weird_msg(msg)

Value

For detection functions: Logical TRUE if the error condition is met. For message functions: Character vector with the error message.

Arguments

msg

Character string containing the error message or API URL

owner

Character string containing the owner name

repo

Character string containing the repository name

Error Detection Functions

These functions check error messages for specific patterns:

  • has_timeout(): Detects timeout errors

  • need_auth(): Detects authentication errors

  • api_rate_reached(): Detects rate limit errors

  • has_no_http(): Detects HTTP connection errors

  • is_not_found(): Detects resource not found errors

  • is_orgs_call(): Detects organization API calls

  • is_user_call(): Detects user API calls

  • is_repo_call(): Detects repository API calls

Error Message Functions

These functions generate formatted error messages with troubleshooting tips:

  • timeout_msg: Timeout error message

  • auth_msg: Authentication error message

  • api_rate_msg: Rate limit error message

  • no_resource_msg: Resource not found error message

  • no_http_msg: HTTP connection error message

  • wrong_repo_msg(): Repository not found error message

  • wrong_username_msg(): User not found error message

  • wrong_org_name_msg(): Organization not found error message

  • weird_msg(): Generic error message for unknown errors

Examples

Run this code
# Check for error conditions
error_msg <- "API rate limit exceeded for 123.123.123.123"
IssueTrackeR:::api_rate_reached(error_msg)

# Check API call type
api_url <- "https://api.github.com/repos/owner/repo"
IssueTrackeR:::is_repo_call(api_url)
IssueTrackeR:::is_not_found(error_msg)

# Handle unknown errors
unknown_error <- "Unknown error occurred"
IssueTrackeR:::weird_msg(unknown_error)

Run the code above in your browser using DataLab