mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 05:52:45 +00:00 
			
		
		
		
	exceptions
This commit is contained in:
		
							parent
							
								
									36c9c6eb6d
								
							
						
					
					
						commit
						2a2656c5dd
					
				
					 2 changed files with 15 additions and 6 deletions
				
			
		|  | @ -87,4 +87,10 @@ class NotStarted(APIError): | |||
|     """Raised when a call is made before start is called.""" | ||||
|     def __init__(self): | ||||
|         msg = 'You must call `await <Github_instance>.start()` before making this call.' | ||||
|         super().__init__(msg) | ||||
| 
 | ||||
| class RepositoryAlreadyExists(APIError): | ||||
|     """Raised when a repository already exists.""" | ||||
|     def __init__(self): | ||||
|         msg = 'The repository you are trying to create already exists.' | ||||
|         super().__init__(msg) | ||||
|  | @ -8,6 +8,7 @@ import re | |||
| import json | ||||
| 
 | ||||
| from .exceptions import * | ||||
| from .exceptions import RepositoryAlreadyExists | ||||
| from .objects import * | ||||
| from .urls import * | ||||
| 
 | ||||
|  | @ -144,12 +145,14 @@ async def get_repo_issue(session: aiohttp.ClientSession, owner: str, repo_name: | |||
| async def make_repo(session: aiohttp.ClientSession, name: str) -> Repository: | ||||
|     """Creates a new repo with the given name.""" | ||||
|     _data = {"name" : name} | ||||
|     try: | ||||
|         result = await session.post(MAKE_REPO_URL, data= json.dumps(_data)) | ||||
|         if result.status == 201: | ||||
|             return Repository(await result.json(), session) | ||||
|     except Exception: | ||||
|         print(Exception) | ||||
|     result = await session.post(MAKE_REPO_URL, data= json.dumps(_data)) | ||||
|     if result.status == 201: | ||||
|         return Repository(await result.json(), session) | ||||
|     if result.status == 401: | ||||
|         raise NoAuthProvided | ||||
|     raise RepositoryAlreadyExists | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| # org-related functions / utils | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 VarMonke
						VarMonke