Skip to content

Commit

Permalink
Merge pull request #462 from dvonthenen/reexpose-error-classes
Browse files Browse the repository at this point in the history
Re-expose Error Classes
  • Loading branch information
dvonthenen authored Sep 10, 2024
2 parents 66e649b + 0afce18 commit abc610e
Show file tree
Hide file tree
Showing 39 changed files with 37 additions and 163 deletions.
11 changes: 9 additions & 2 deletions deepgram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@

from .client import Deepgram, DeepgramClient
from .client import DeepgramClientOptions, ClientOptionsFromEnv
from .client import DeepgramApiKeyError, DeepgramModuleError
from .client import (
DeepgramError,
DeepgramTypeError,
DeepgramModuleError,
DeepgramApiError,
DeepgramUnknownApiError,
)
from .errors import DeepgramApiKeyError

# listen/read client
from .client import Listen, Read
Expand Down Expand Up @@ -173,7 +180,7 @@
)

# utilities
from .audio import Microphone
from .audio import Microphone, DeepgramMicrophoneError
from .audio import (
LOGGING,
CHANNELS,
Expand Down
1 change: 1 addition & 0 deletions deepgram/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

from .microphone import Microphone
from .microphone import LOGGING, CHANNELS, RATE, CHUNK
from .microphone import DeepgramMicrophoneError
1 change: 1 addition & 0 deletions deepgram/audio/microphone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

from .microphone import Microphone
from .constants import LOGGING, CHANNELS, RATE, CHUNK
from .errors import DeepgramMicrophoneError
9 changes: 8 additions & 1 deletion deepgram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
UnhandledResponse,
ErrorResponse,
)
from .clients import (
DeepgramError,
DeepgramTypeError,
DeepgramModuleError,
DeepgramApiError,
DeepgramUnknownApiError,
)

# listen client
from .clients import Listen, Read, Speak
Expand Down Expand Up @@ -178,7 +185,7 @@

# client errors and options
from .options import DeepgramClientOptions, ClientOptionsFromEnv
from .errors import DeepgramApiKeyError, DeepgramModuleError
from .errors import DeepgramApiKeyError

# pylint: enable=unused-import

Expand Down
2 changes: 2 additions & 0 deletions deepgram/clients/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
UnhandledResponse,
ErrorResponse,
)
from .common import DeepgramError, DeepgramTypeError
from .errors import DeepgramModuleError, DeepgramApiError, DeepgramUnknownApiError

from .listen_router import Listen
from .read_router import Read
Expand Down
3 changes: 2 additions & 1 deletion deepgram/clients/abstract_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from .helpers import append_query_params
from ..options import DeepgramClientOptions
from .errors import DeepgramError, DeepgramApiError, DeepgramUnknownApiError
from .errors import DeepgramApiError, DeepgramUnknownApiError
from .common.v1.errors import DeepgramError


class AbstractAsyncRestClient:
Expand Down
3 changes: 2 additions & 1 deletion deepgram/clients/abstract_sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

from .helpers import append_query_params
from ..options import DeepgramClientOptions
from .errors import DeepgramError, DeepgramApiError, DeepgramUnknownApiError
from .errors import DeepgramApiError, DeepgramUnknownApiError
from .common.v1.errors import DeepgramError


class AbstractSyncRestClient:
Expand Down
2 changes: 0 additions & 2 deletions deepgram/clients/analyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
from .client import AnalyzeOptions
from .client import UrlSource, FileSource, AnalyzeStreamSource, AnalyzeSource
from .client import AsyncAnalyzeResponse, AnalyzeResponse, SyncAnalyzeResponse

from ...options import DeepgramClientOptions, ClientOptionsFromEnv
1 change: 0 additions & 1 deletion deepgram/clients/analyze/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
AnalyzeStreamSource,
AnalyzeSource,
)
from ....options import DeepgramClientOptions, ClientOptionsFromEnv
from .response import AsyncAnalyzeResponse, AnalyzeResponse, Sentiment
2 changes: 1 addition & 1 deletion deepgram/clients/analyze/v1/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ....utils import verboselogs
from ....options import DeepgramClientOptions
from ...abstract_async_client import AbstractAsyncRestClient
from ..errors import DeepgramError, DeepgramTypeError
from ...common.v1.errors import DeepgramError, DeepgramTypeError

from .helpers import is_buffer_source, is_readstream_source, is_url_source
from .options import (
Expand Down
2 changes: 1 addition & 1 deletion deepgram/clients/analyze/v1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ....utils import verboselogs
from ....options import DeepgramClientOptions
from ...abstract_sync_client import AbstractSyncRestClient
from ..errors import DeepgramError, DeepgramTypeError
from ...common.v1.errors import DeepgramError, DeepgramTypeError

from .helpers import is_buffer_source, is_readstream_source, is_url_source
from .options import (
Expand Down
3 changes: 2 additions & 1 deletion deepgram/clients/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT

from .v1 import DeepgramError, DeepgramTypeError

from .v1 import (
TextSource as TextSourceLatest,
BufferSource as BufferSourceLatest,
Expand All @@ -16,6 +18,5 @@
BufferSource = BufferSourceLatest
StreamSource = StreamSourceLatest


Sentiment = SentimentLatest
FileSource = FileSourceLatest
2 changes: 2 additions & 0 deletions deepgram/clients/common/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from .enums import Sentiment

from .errors import DeepgramError, DeepgramTypeError

from .options import (
TextSource,
BufferSource,
Expand Down
File renamed without changes.
17 changes: 0 additions & 17 deletions deepgram/clients/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,6 @@
# SPDX-License-Identifier: MIT


class DeepgramError(Exception):
"""
Exception raised for unknown errors related to the Deepgram API.
Attributes:
message (str): The error message describing the exception.
"""

def __init__(self, message: str):
super().__init__(message)
self.name = "DeepgramError"
self.message = message

def __str__(self):
return f"{self.name}: {self.message}"


class DeepgramModuleError(Exception):
"""
Base class for exceptions raised for a missing Deepgram module.
Expand Down
1 change: 0 additions & 1 deletion deepgram/clients/listen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: MIT

from .enums import LiveTranscriptionEvents
from ...options import DeepgramClientOptions, ClientOptionsFromEnv

# backward compat
from .client import (
Expand Down
3 changes: 0 additions & 3 deletions deepgram/clients/listen/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT


# from ...options import DeepgramClientOptions, ClientOptionsFromEnv

# rest
from .v1 import (
ListenRESTClient as ListenRESTClientLatest,
Expand Down
54 changes: 0 additions & 54 deletions deepgram/clients/listen/errors.py

This file was deleted.

2 changes: 0 additions & 2 deletions deepgram/clients/listen/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT

from ....options import DeepgramClientOptions, ClientOptionsFromEnv

# backward compat
from .rest import (
ListenRESTClient as PreRecordedClient,
Expand Down
2 changes: 0 additions & 2 deletions deepgram/clients/listen/v1/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
SyncPrerecordedResponse,
Sentiment,
)

from .....options import DeepgramClientOptions, ClientOptionsFromEnv
2 changes: 1 addition & 1 deletion deepgram/clients/listen/v1/rest/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .....utils import verboselogs
from .....options import DeepgramClientOptions
from ....abstract_async_client import AbstractAsyncRestClient
from ...errors import DeepgramError, DeepgramTypeError
from ....common.v1.errors import DeepgramError, DeepgramTypeError

from .helpers import is_buffer_source, is_readstream_source, is_url_source
from .options import (
Expand Down
2 changes: 1 addition & 1 deletion deepgram/clients/listen/v1/rest/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .....utils import verboselogs
from .....options import DeepgramClientOptions
from ....abstract_sync_client import AbstractSyncRestClient
from ...errors import DeepgramError, DeepgramTypeError
from ....common.v1.errors import DeepgramError, DeepgramTypeError

from .helpers import is_buffer_source, is_readstream_source, is_url_source
from .options import (
Expand Down
1 change: 0 additions & 1 deletion deepgram/clients/listen/v1/websocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from .client import ListenWebSocketClient
from .async_client import AsyncListenWebSocketClient
from .options import LiveOptions, ListenWebSocketOptions
from .....options import DeepgramClientOptions, ClientOptionsFromEnv
from .response import (
OpenResponse,
LiveResultResponse,
Expand Down
2 changes: 1 addition & 1 deletion deepgram/clients/listen/v1/websocket/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .....options import DeepgramClientOptions
from ...enums import LiveTranscriptionEvents
from ..helpers import convert_to_websocket_url, append_query_params
from ...errors import DeepgramError
from ....common.v1.errors import DeepgramError

from .response import (
OpenResponse,
Expand Down
2 changes: 1 addition & 1 deletion deepgram/clients/listen/v1/websocket/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .....options import DeepgramClientOptions
from ...enums import LiveTranscriptionEvents
from ..helpers import convert_to_websocket_url, append_query_params
from ...errors import DeepgramError
from ....common.v1.errors import DeepgramError

from .response import (
OpenResponse,
Expand Down
1 change: 0 additions & 1 deletion deepgram/clients/live/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: MIT

from .v1 import LiveTranscriptionEvents
from .v1 import DeepgramError, DeepgramTypeError, DeepgramWebsocketError

from .v1 import LiveClient
from .v1 import AsyncLiveClient
Expand Down
1 change: 0 additions & 1 deletion deepgram/clients/live/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: MIT

from .enums import LiveTranscriptionEvents
from .errors import DeepgramError, DeepgramTypeError, DeepgramWebsocketError

from .client import LiveClient
from .client import AsyncLiveClient
Expand Down
5 changes: 0 additions & 5 deletions deepgram/clients/live/v1/errors.py

This file was deleted.

1 change: 0 additions & 1 deletion deepgram/clients/manage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@
ModelResponse,
ModelsResponse,
)
from ...options import DeepgramClientOptions, ClientOptionsFromEnv
2 changes: 0 additions & 2 deletions deepgram/clients/prerecorded/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT

from ...options import DeepgramClientOptions, ClientOptionsFromEnv

from .v1 import PreRecordedClient
from .v1 import AsyncPreRecordedClient
from .v1 import PrerecordedOptions
Expand Down
2 changes: 0 additions & 2 deletions deepgram/clients/prerecorded/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Use of this source code is governed by a MIT license that can be found in the LICENSE file.
# SPDX-License-Identifier: MIT

from ....options import DeepgramClientOptions, ClientOptionsFromEnv

from .client import PreRecordedClient
from .client import AsyncPreRecordedClient
from .client import PrerecordedOptions
Expand Down
1 change: 0 additions & 1 deletion deepgram/clients/selfhosted/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

from .client import SelfHostedClient, OnPremClient
from .client import AsyncSelfHostedClient, AsyncOnPremClient
from ...options import DeepgramClientOptions, ClientOptionsFromEnv
1 change: 0 additions & 1 deletion deepgram/clients/selfhosted/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

from .client import SelfHostedClient
from .async_client import AsyncSelfHostedClient
from ....options import DeepgramClientOptions, ClientOptionsFromEnv
1 change: 0 additions & 1 deletion deepgram/clients/speak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# SPDX-License-Identifier: MIT

from .enums import SpeakWebSocketEvents
from ...options import DeepgramClientOptions, ClientOptionsFromEnv

from .client import (
SpeakClient, # backward compat
Expand Down
37 changes: 0 additions & 37 deletions deepgram/clients/speak/errors.py

This file was deleted.

Loading

0 comments on commit abc610e

Please sign in to comment.