Created PyApiException

Added custom error_code throwing