@@ -18,7 +18,7 @@ def _internal_exceptions():
18
18
except Exception :
19
19
hub = Hub .current
20
20
if hub :
21
- hub .capture_internal_exception (sys .exc_info ())
21
+ hub ._capture_internal_exception (sys .exc_info ())
22
22
23
23
24
24
def _get_client_options ():
@@ -124,7 +124,13 @@ def bind_client(self, new):
124
124
self ._stack [- 1 ] = (new , top [1 ])
125
125
126
126
def capture_event (self , event , hint = None ):
127
- """Captures an event."""
127
+ """Captures an event. The return value is the ID of the event.
128
+
129
+ The event is a dictionary following the Sentry v7/v8 protocol
130
+ specification. Optionally an `EventHint` object can be passed that
131
+ is used by processors to extract additional information from it.
132
+ Typically the event hint object would contain exception information.
133
+ """
128
134
client , scope = self ._stack [- 1 ]
129
135
if client is not None :
130
136
rv = client .capture_event (event , hint , scope )
@@ -133,15 +139,22 @@ def capture_event(self, event, hint=None):
133
139
return rv
134
140
135
141
def capture_message (self , message , level = None ):
136
- """Captures a message."""
142
+ """Captures a message. The message is just a string. If no level
143
+ is provided the default level is `info`.
144
+ """
137
145
if self .client is None :
138
146
return
139
147
if level is None :
140
148
level = "info"
141
149
return self .capture_event ({"message" : message , "level" : level })
142
150
143
151
def capture_exception (self , error = None ):
144
- """Captures an exception."""
152
+ """Captures an exception.
153
+
154
+ The argument passed can be `None` in which case the last exception
155
+ will be reported, otherwise an exception object or an `exc_info`
156
+ tuple.
157
+ """
145
158
client = self .client
146
159
if client is None :
147
160
return
@@ -156,15 +169,19 @@ def capture_exception(self, error=None):
156
169
try :
157
170
return self .capture_event (event , hint = hint )
158
171
except Exception :
159
- self .capture_internal_exception (sys .exc_info ())
172
+ self ._capture_internal_exception (sys .exc_info ())
160
173
161
- def capture_internal_exception (self , exc_info ):
174
+ def _capture_internal_exception (self , exc_info ):
162
175
"""Capture an exception that is likely caused by a bug in the SDK
163
176
itself."""
164
177
logger .debug ("Internal error in sentry_sdk" , exc_info = exc_info )
165
178
166
179
def add_breadcrumb (self , crumb = None , hint = None , ** kwargs ):
167
- """Adds a breadcrumb."""
180
+ """Adds a breadcrumb. The breadcrumbs are a dictionary with the
181
+ data as the sentry v7/v8 protocol expects. `hint` is an optional
182
+ value that can be used by `before_breadcrumb` to customize the
183
+ breadcrumbs that are emitted.
184
+ """
168
185
client , scope = self ._stack [- 1 ]
169
186
if client is None :
170
187
logger .info ("Dropped breadcrumb because no client bound" )
0 commit comments