Repository: easybuilders/easybuild-framework

Issue:
traceback when providing incorrect PR id to --include-easyblocks-from-pr
Example (copy-paste mistake):

```
$ eb --from-pr 11000 --include-easyblocks-from-pr 11000
== temporary log file in case of crash /tmp/eb-UYthfY/easybuild-MIOaI3.log
Traceback (most recent call last):
  File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/main.py", line 533, in <module>
    main()
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/main.py", line 204, in main
    eb_go, cfg_settings = set_up_configuration(args=args, logfile=logfile, testing=testing)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/tools/options.py", line 1457, in set_up_configuration
    easyblocks_from_pr = fetch_easyblocks_from_pr(pr_easyblocks)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/tools/github.py", line 382, in fetch_easyblocks_from_pr
    return fetch_files_from_pr(pr, path, github_user, github_repo=GITHUB_EASYBLOCKS_REPO)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/tools/github.py", line 425, in fetch_files_from_pr
    pr_data, _ = fetch_pr_data(pr, github_account, github_repo, github_user)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/tools/github.py", line 2133, in fetch_pr_data
    status, pr_data = github_api_get_request(pr_url, github_user, **parameters)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/tools/github.py", line 255, in github_api_get_request
    status, data = url.get(**kwargs)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/base/rest.py", line 113, in get
    return self.request(self.GET, url, None, headers)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/base/rest.py", line 174, in request
    conn = self.get_connection(method, url, body, headers)
  File "/lib/python2.7/site-packages/easybuild_framework-4.2.3.dev0-py2.7.egg/easybuild/base/rest.py", line 215, in get_connection
    connection = self.opener.open(request)
  File "/usr/lib64/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found
```


Discussion:
well, that's also the behaviour of `--from-pr`, isn't it? :p




Resolving patch:
diff --git a/easybuild/tools/github.py b/easybuild/tools/github.py
--- a/easybuild/tools/github.py
+++ b/easybuild/tools/github.py
@@ -2167,7 +2167,13 @@ def pr_url(gh):
         else:
             return gh.repos[pr_target_account][pr_target_repo].pulls[pr]
 
-    status, pr_data = github_api_get_request(pr_url, github_user, **parameters)
+    try:
+        status, pr_data = github_api_get_request(pr_url, github_user, **parameters)
+    except HTTPError as err:
+        raise EasyBuildError("Failed to get data for PR #%d from %s/%s (%s)\n"
+                             "Please check PR #, account and repo.",
+                             pr, pr_target_account, pr_target_repo, err)
+
     if status != HTTP_STATUS_OK:
         raise EasyBuildError("Failed to get data for PR #%d from %s/%s (status: %d %s)",
                              pr, pr_target_account, pr_target_repo, status, pr_data)


Test patch: