exception.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import {t} from 'sentry/locale';
  2. import {ExceptionType, Group, PlatformKey, Project} from 'sentry/types';
  3. import {EntryType, Event} from 'sentry/types/event';
  4. import {StackType, StackView} from 'sentry/types/stacktrace';
  5. import {PermalinkTitle, TraceEventDataSection} from '../traceEventDataSection';
  6. import {ExceptionContent} from './crashContent/exception';
  7. import NoStackTraceMessage from './noStackTraceMessage';
  8. import {isStacktraceNewestFirst} from './utils';
  9. type Props = {
  10. data: ExceptionType;
  11. event: Event;
  12. hasHierarchicalGrouping: boolean;
  13. projectSlug: Project['slug'];
  14. groupingCurrentLevel?: Group['metadata']['current_level'];
  15. hideGuide?: boolean;
  16. };
  17. export function Exception({
  18. event,
  19. data,
  20. projectSlug,
  21. hasHierarchicalGrouping,
  22. groupingCurrentLevel,
  23. }: Props) {
  24. const eventHasThreads = !!event.entries.some(entry => entry.type === EntryType.THREADS);
  25. // in case there are threads in the event data, we don't render the
  26. // exception block. Instead the exception is contained within the
  27. // thread interface.
  28. if (eventHasThreads) {
  29. return null;
  30. }
  31. const entryIndex = event.entries.findIndex(
  32. eventEntry => eventEntry.type === EntryType.EXCEPTION
  33. );
  34. const meta = event._meta?.entries?.[entryIndex]?.data?.values;
  35. function getPlatform(): PlatformKey {
  36. const dataValue = data.values?.find(
  37. value => !!value.stacktrace?.frames?.some(frame => !!frame.platform)
  38. );
  39. if (dataValue) {
  40. const framePlatform = dataValue.stacktrace?.frames?.find(frame => !!frame.platform);
  41. if (framePlatform?.platform) {
  42. return framePlatform.platform;
  43. }
  44. }
  45. return event.platform ?? 'other';
  46. }
  47. const stackTraceNotFound = !(data.values ?? []).length;
  48. const platform = getPlatform();
  49. return (
  50. <TraceEventDataSection
  51. title={<PermalinkTitle>{t('Stack Trace')}</PermalinkTitle>}
  52. type={EntryType.EXCEPTION}
  53. projectSlug={projectSlug}
  54. eventId={event.id}
  55. recentFirst={isStacktraceNewestFirst()}
  56. fullStackTrace={!data.hasSystemFrames}
  57. platform={platform}
  58. hasMinified={!!data.values?.some(value => value.rawStacktrace)}
  59. hasVerboseFunctionNames={
  60. !!data.values?.some(
  61. value =>
  62. !!value.stacktrace?.frames?.some(
  63. frame =>
  64. !!frame.rawFunction &&
  65. !!frame.function &&
  66. frame.rawFunction !== frame.function
  67. )
  68. )
  69. }
  70. hasAbsoluteFilePaths={
  71. !!data.values?.some(
  72. value => !!value.stacktrace?.frames?.some(frame => !!frame.filename)
  73. )
  74. }
  75. hasAbsoluteAddresses={
  76. !!data.values?.some(
  77. value => !!value.stacktrace?.frames?.some(frame => !!frame.instructionAddr)
  78. )
  79. }
  80. hasAppOnlyFrames={
  81. !!data.values?.some(
  82. value => !!value.stacktrace?.frames?.some(frame => frame.inApp !== true)
  83. )
  84. }
  85. hasNewestFirst={
  86. !!data.values?.some(value => (value.stacktrace?.frames ?? []).length > 1)
  87. }
  88. stackTraceNotFound={stackTraceNotFound}
  89. wrapTitle={false}
  90. >
  91. {({recentFirst, display, fullStackTrace}) =>
  92. stackTraceNotFound ? (
  93. <NoStackTraceMessage />
  94. ) : (
  95. <ExceptionContent
  96. stackType={
  97. display.includes('minified') ? StackType.MINIFIED : StackType.ORIGINAL
  98. }
  99. stackView={
  100. display.includes('raw-stack-trace')
  101. ? StackView.RAW
  102. : fullStackTrace
  103. ? StackView.FULL
  104. : StackView.APP
  105. }
  106. projectSlug={projectSlug}
  107. newestFirst={recentFirst}
  108. event={event}
  109. platform={platform}
  110. values={data.values}
  111. groupingCurrentLevel={groupingCurrentLevel}
  112. hasHierarchicalGrouping={hasHierarchicalGrouping}
  113. meta={meta}
  114. />
  115. )
  116. }
  117. </TraceEventDataSection>
  118. );
  119. }