-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pretty error msg when init location is invalid (#1606)
* Pretty error msg when init location is invalid * stringify path for windows
- Loading branch information
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
from pathlib import Path | ||
from cookiecutter import repository | ||
from cookiecutter import exceptions | ||
from cookiecutter import config | ||
|
||
from samcli.lib.utils import osutils | ||
|
@@ -17,6 +18,16 @@ | |
LOG = logging.getLogger(__name__) | ||
|
||
|
||
BAD_LOCATION_ERROR_MSG = ( | ||
"Please verify your location. The following types of location are supported:" | ||
"\n\n* Github: gh:user/repo (or) https://github.com/user/repo (or) [email protected]:user/repo.git" | ||
"\n For Git repositories, you must use location of the root of the repository." | ||
"\n\n* Mercurial: hg+ssh://[email protected]/repo" | ||
"\n\n* Http(s): https://example.com/code.zip" | ||
"\n\n* Local Path: /path/to/code.zip" | ||
) | ||
|
||
|
||
def generate_non_cookiecutter_project(location, output_dir): | ||
""" | ||
Uses Cookiecutter APIs to download a project at given ``location`` to the ``output_dir``. | ||
|
@@ -65,9 +76,13 @@ def generate_non_cookiecutter_project(location, output_dir): | |
download_fn = functools.partial(repository.clone, repo_url=location, no_input=no_input) | ||
|
||
else: | ||
raise ArbitraryProjectDownloadFailed(msg="Unsupported location {location}".format(location=location)) | ||
raise ArbitraryProjectDownloadFailed(msg=BAD_LOCATION_ERROR_MSG) | ||
|
||
return _download_and_copy(download_fn, output_dir) | ||
try: | ||
return _download_and_copy(download_fn, output_dir) | ||
except exceptions.RepositoryNotFound: | ||
# Download failed because the zip or the repository was not found | ||
raise ArbitraryProjectDownloadFailed(msg=BAD_LOCATION_ERROR_MSG) | ||
|
||
|
||
def _download_and_copy(download_fn, output_dir): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters