omerXfaruq commited on
Commit
8cc97ab
1 Parent(s): 7401495

Add exception catching to create_repo function

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -56,7 +56,12 @@ class SpaceBuilder:
56
  :return: True if success
57
  """
58
  name_list = cls.split_space_names(names)
59
- create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
 
 
 
 
 
60
  repo_name = get_full_repo_name(model_id=space_name, token=hf_token)
61
 
62
  try:
 
56
  :return: True if success
57
  """
58
  name_list = cls.split_space_names(names)
59
+ try:
60
+ create_repo(name=space_name, token=hf_token, repo_type="space", space_sdk="gradio")
61
+ except Exception as ex:
62
+ print(ex)
63
+ cls.error_message = "Please provied a correct space name as Only regular characters and '-', '_', '.' accepted. '--' and '..' are forbidden. '-' and '.' cannot start or end the name."
64
+ return False
65
  repo_name = get_full_repo_name(model_id=space_name, token=hf_token)
66
 
67
  try: