Skip to content

Commit

Permalink
fix: Change exception type for missing location header
Browse files Browse the repository at this point in the history
  • Loading branch information
congminh1254 committed May 11, 2024
1 parent 8e0d640 commit bacbcf8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions boxsdk/object/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from datetime import datetime
from typing import TYPE_CHECKING, Optional, Tuple, Union, IO, Iterable, List, Any
from boxsdk.exception import BoxException
from boxsdk.exception import BoxAPIException

from boxsdk.util.datetime_formatter import normalize_date_to_rfc3339_format
from .item import Item
Expand Down Expand Up @@ -178,8 +178,16 @@ def get_download_url(self, file_version: Optional['FileVersion'] = None) -> str:
expect_json_response=False,
allow_redirects=False,
)
network_response = box_response.network_response
if 'location' not in box_response.headers:
raise BoxException('Download URL is not present in the response.')
raise BoxAPIException(
status=network_response.status_code,
headers=network_response.headers,
message='Download URL is not present in the response.',
url=url,
method='GET',
network_response=network_response,
)

return box_response.headers['location']

Expand Down

0 comments on commit bacbcf8

Please sign in to comment.