Skip to content

Commit

Permalink
Make exceptions private
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Apr 13, 2022
1 parent e48f12f commit 88f3a06
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from typing import List


class Failure(Exception):
class _Failure(Exception):
"Exception raised when a function fails"

def __init__(self, method: str, exceptions: List[Exception]):
Expand All @@ -35,5 +35,5 @@ def __str__(self) -> str:
)


class Timeout(Exception):
class _Timeout(Exception):
"Exception raised when a function times out"
4 changes: 2 additions & 2 deletions opentelemetry-sdk/src/opentelemetry/sdk/_metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.util._once import Once
from opentelemetry.util.exceptions import Failure
from opentelemetry.util.exceptions import _Failure

_logger = getLogger(__name__)

Expand Down Expand Up @@ -334,7 +334,7 @@ def _shutdown():
self._atexit_handler = None

if metric_reader_errors:
raise Failure("MeterProvider.shutdown", metric_reader_errors)
raise _Failure("MeterProvider.shutdown", metric_reader_errors)

def get_meter(
self,
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-sdk/tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from opentelemetry.sdk._metrics.point import AggregationTemporality
from opentelemetry.sdk.resources import Resource
from opentelemetry.test.concurrency_test import ConcurrencyTestBase, MockFunc
from opentelemetry.util.exceptions import Failure
from opentelemetry.util.exceptions import _Failure


class DummyMetricReader(MetricReader):
Expand Down Expand Up @@ -162,12 +162,12 @@ def test_shutdown(self):
metric_readers=[mock_metric_reader_0, mock_metric_reader_1]
)

with self.assertRaises(Failure) as error:
with self.assertRaises(_Failure) as error:
meter_provider.shutdown()

error = error.exception

self.assertIsInstance(error, Failure)
self.assertIsInstance(error, _Failure)
self.assertEqual(
str(error),
(
Expand Down

0 comments on commit 88f3a06

Please sign in to comment.