Skip to content

Commit b28caa3

Browse files
Improve error messages in LinearSolveAutotune telemetry (#703)
- Add detailed error reporting in upload_to_github with specific error types - Include repository, issue number, and auth method in error output - Provide actionable guidance for common errors (403, 404, 401, rate limits) - Show specific help messages for permission issues - Include the GitHub issue URL in fallback message for manual sharing - Improve error propagation in comment_on_issue functions - Use @error for critical failures and @debug for detailed diagnostics This helps users understand why uploads fail and what actions to take.
1 parent 1c61e01 commit b28caa3

File tree

1 file changed

+45
-6
lines changed

1 file changed

+45
-6
lines changed

lib/LinearSolveAutotune/src/telemetry.jl

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,29 @@ function upload_to_github(content::String, plot_files, auth_info::Tuple,
408408
end
409409

410410
catch e
411-
@warn "❌ Failed to add comment to GitHub issue: $e"
412-
@info "💡 This could be due to network issues, repository permissions, or API limits."
411+
@error "❌ Failed to add comment to GitHub issue #$issue_number"
412+
@error " Repository: $target_repo"
413+
@error " Auth method: $auth_method"
414+
@error " Error type: $(typeof(e))"
415+
@error " Error message: $e"
416+
417+
# Provide specific guidance based on error type
418+
if occursin("403", string(e)) || occursin("forbidden", lowercase(string(e)))
419+
@info "📝 This appears to be a permissions issue. Possible causes:"
420+
@info " 1. You may not have write access to $target_repo"
421+
@info " 2. Your token may lack the 'public_repo' or 'repo' scope"
422+
@info " 3. The repository may have restricted commenting"
423+
@info " Try: gh auth status to check your authentication"
424+
elseif occursin("404", string(e)) || occursin("not found", lowercase(string(e)))
425+
@info "📝 Issue #$issue_number was not found. The issue may have been deleted or moved."
426+
elseif occursin("401", string(e)) || occursin("unauthorized", lowercase(string(e)))
427+
@info "📝 Authentication failed. Your token may have expired or been revoked."
428+
@info " Try: gh auth login to re-authenticate"
429+
elseif occursin("rate limit", lowercase(string(e)))
430+
@info "📝 GitHub API rate limit exceeded. Try again later."
431+
else
432+
@info "💡 This could be due to network issues, repository permissions, or API limits."
433+
end
413434

414435
# Save locally as fallback
415436
timestamp = replace(string(Dates.now()), ":" => "-")
@@ -418,6 +439,8 @@ function upload_to_github(content::String, plot_files, auth_info::Tuple,
418439
write(f, content)
419440
end
420441
@info "📁 Results saved locally to $fallback_file as backup"
442+
@info " You can manually share this file on the issue tracker:"
443+
@info " https://github.com/$target_repo/issues/$issue_number"
421444
end
422445
end
423446

@@ -749,8 +772,11 @@ function comment_on_issue_api(target_repo, issue_number, body, auth)
749772
@info "✅ Added comment to issue #$(issue_number) via API"
750773
return "https://github.com/$(target_repo)/issues/$(issue_number)#issuecomment-$(comment.id)"
751774
catch e
752-
@warn "Failed to add comment via API: $e"
753-
return nothing
775+
@debug "Failed to add comment via API"
776+
@debug " Error type: $(typeof(e))"
777+
@debug " Error details: $e"
778+
# Re-throw to let the parent function handle and display the error
779+
rethrow(e)
754780
end
755781
end
756782

@@ -784,8 +810,21 @@ function comment_on_issue_gh(target_repo, issue_number, body)
784810
return "https://github.com/$(target_repo)/issues/$(issue_number)"
785811
end
786812
catch e
787-
@warn "Failed to add comment via `gh` CLI: $e" out_str err_str
788-
return nothing
813+
@debug "Failed to add comment via gh CLI"
814+
@debug " Command output: $out_str"
815+
@debug " Command stderr: $err_str"
816+
@debug " Error type: $(typeof(e))"
817+
@debug " Error details: $e"
818+
819+
# Create a more informative error message
820+
error_msg = if !isempty(err_str)
821+
"gh CLI error: $err_str"
822+
else
823+
"gh CLI command failed: $e"
824+
end
825+
826+
# Re-throw with more context
827+
error(error_msg)
789828
end
790829
end
791830

0 commit comments

Comments
 (0)