Skip to content

Commit

Permalink
Address code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Oct 7, 2024
1 parent aadb961 commit 3c0c421
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions google/cloud/spanner_v1/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
)
from google.cloud.spanner_v1._opentelemetry_tracing import (
get_current_span,
set_span_error_and_record_exception,
trace_call,
)
from google.cloud.spanner_v1.batch import Batch
Expand Down Expand Up @@ -117,11 +116,10 @@ def name(self):
:raises ValueError: if session is not yet created
"""
if self._session_id is None:
err = "No session available"
err_message = "No session ID set by back-end"
current_span = get_current_span()
current_span.add_event(err)
set_span_error_and_record_exception(current_span, err)
raise ValueError("No session ID set by back-end")
current_span.add_event(err_message)
raise ValueError(err_message)
return self._database.name + "/sessions/" + self._session_id

def create(self):
Expand All @@ -136,10 +134,9 @@ def create(self):
current_span.add_event("Creating Session")

if self._session_id is not None:
err = "Session ID already set by back-end"
current_span.add_event(err)
set_span_error_and_record_exception(current_span, err)
raise ValueError(err)
err_message = "Session ID already set by back-end"
current_span.add_event(err_message)
raise ValueError(err_message)
api = self._database.spanner_api
metadata = _metadata_with_prefix(self._database.name)
if self._database._route_to_leader_enabled:
Expand Down

0 comments on commit 3c0c421

Please sign in to comment.