Skip to content

Commit 9cb37d4

Browse files
shayna-chbillyvg
authored andcommitted
chore(markdown): add handled to copy to markdown (#117889)
1 parent 6c80b31 commit 9cb37d4

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

static/app/views/issueDetails/hooks/useCopyIssueDetails.spec.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,64 @@ describe('useCopyIssueDetails', () => {
206206
expect(result).toContain('**Type:** TypeError');
207207
expect(result).toContain('**Value:** Cannot read property of undefined');
208208
expect(result).toContain('#### Stacktrace');
209+
// No mechanism on this exception, so no handled line.
210+
expect(result).not.toContain('**Handled:**');
211+
});
212+
213+
it('marks an unhandled exception', () => {
214+
const eventWithUnhandled = EventFixture({
215+
...event,
216+
entries: [
217+
{
218+
type: EntryType.EXCEPTION,
219+
data: {
220+
values: [
221+
{
222+
type: 'TypeError',
223+
value: 'boom',
224+
mechanism: {type: 'onerror', handled: false},
225+
},
226+
],
227+
},
228+
},
229+
],
230+
});
231+
232+
const result = issueAndEventToMarkdown({
233+
group,
234+
event: eventWithUnhandled,
235+
organization,
236+
});
237+
238+
expect(result).toContain('**Handled:** No');
239+
});
240+
241+
it('marks a handled exception', () => {
242+
const eventWithHandled = EventFixture({
243+
...event,
244+
entries: [
245+
{
246+
type: EntryType.EXCEPTION,
247+
data: {
248+
values: [
249+
{
250+
type: 'ValueError',
251+
value: 'caught',
252+
mechanism: {type: 'generic', handled: true},
253+
},
254+
],
255+
},
256+
},
257+
],
258+
});
259+
260+
const result = issueAndEventToMarkdown({
261+
group,
262+
event: eventWithHandled,
263+
organization,
264+
});
265+
266+
expect(result).toContain('**Handled:** Yes');
209267
});
210268

211269
it('includes thread stacktrace when activeThreadId matches', () => {

static/app/views/issueDetails/hooks/useCopyIssueDetails.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ function formatEventToMarkdown(event: Event, activeThreadId: number | undefined)
203203
if (exception.type) {
204204
markdownText += `**Type:** ${exception.type}\n`;
205205
}
206+
// Mirror Seer's `is_exception_handled`: an unhandled exception crashed
207+
// the program, a handled one was caught. Only emit it when known.
208+
const handled = exception.mechanism?.handled;
209+
if (handled !== null && handled !== undefined) {
210+
markdownText += `**Handled:** ${handled ? 'Yes' : 'No'}\n`;
211+
}
206212
if (exception.value) {
207213
markdownText += `**Value:** ${exception.value}\n\n`;
208214
}

0 commit comments

Comments
 (0)