#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:platform: Unix
:synopsis: Custom exceptions used in this module.
"""
###################################
# Exceptions for GitHub connexion #
###################################
[docs]class GitHubException(Exception):
"""
Basic exception for GitHub errors.
"""
# API call url
URI = []
def __init__(self, msg):
self.uri = GitHubException.URI
self.msg = msg
self.msg += "\n<url: '{}'>".format(self.uri)
super(GitHubException, self).__init__(self.msg)
[docs]class GitHubUnauthorized(GitHubException):
"""
Raised when no read access on GitHub repo.
"""
def __init__(self):
self.msg = "GitHub permission denied"
super(self.__class__, self).__init__(self.msg)
[docs]class GitHubAPIRateLimit(GitHubException):
"""
Raised when GitHub API rate limit exceeded.
"""
def __init__(self):
self.msg = "GitHub API rate limit exceeded (try again in 60 minutes or submit GitHub user/password)"
super(self.__class__, self).__init__(self.msg)
[docs]class GitHubFileNotFound(GitHubException):
"""
Raised when no file found on GitHub repo.
"""
def __init__(self):
self.msg = "GitHub file not found"
super(self.__class__, self).__init__(self.msg)
[docs]class GitHubConnectionError(GitHubException):
"""
Raised when the GitHub request fails.
"""
def __init__(self):
self.msg = "GitHub connection error"
super(self.__class__, self).__init__(self.msg)