exceptionV2.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import styled from '@emotion/styled';
  2. import {t} from 'sentry/locale';
  3. import {ExceptionType, Group, PlatformType, Project} from 'sentry/types';
  4. import {Event} from 'sentry/types/event';
  5. import {STACK_TYPE, STACK_VIEW} from 'sentry/types/stacktrace';
  6. import TraceEventDataSection from '../traceEventDataSection';
  7. import {DisplayOption} from '../traceEventDataSection/displayOptions';
  8. import CrashContentException from './crashContent/exception';
  9. import NoStackTraceMessage from './noStackTraceMessage';
  10. import {isStacktraceNewestFirst} from './utils';
  11. type Props = {
  12. data: ExceptionType;
  13. event: Event;
  14. hasHierarchicalGrouping: boolean;
  15. projectId: Project['id'];
  16. type: string;
  17. groupingCurrentLevel?: Group['metadata']['current_level'];
  18. hideGuide?: boolean;
  19. };
  20. function Exception({
  21. event,
  22. type,
  23. data,
  24. projectId,
  25. hasHierarchicalGrouping,
  26. groupingCurrentLevel,
  27. }: Props) {
  28. const eventHasThreads = !!event.entries.some(entry => entry.type === 'threads');
  29. /* in case there are threads in the event data, we don't render the
  30. exception block. Instead the exception is contained within the
  31. thread interface. */
  32. if (eventHasThreads) {
  33. return null;
  34. }
  35. function getPlatform(): PlatformType {
  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={<Title>{t('Exception')}</Title>}
  52. type={type}
  53. stackType={STACK_TYPE.ORIGINAL}
  54. projectId={projectId}
  55. eventId={event.id}
  56. recentFirst={isStacktraceNewestFirst()}
  57. fullStackTrace={!data.hasSystemFrames}
  58. platform={platform}
  59. hasMinified={!!data.values?.some(value => value.rawStacktrace)}
  60. hasVerboseFunctionNames={
  61. !!data.values?.some(
  62. value =>
  63. !!value.stacktrace?.frames?.some(
  64. frame =>
  65. !!frame.rawFunction &&
  66. !!frame.function &&
  67. frame.rawFunction !== frame.function
  68. )
  69. )
  70. }
  71. hasAbsoluteFilePaths={
  72. !!data.values?.some(
  73. value => !!value.stacktrace?.frames?.some(frame => !!frame.filename)
  74. )
  75. }
  76. hasAbsoluteAddresses={
  77. !!data.values?.some(
  78. value => !!value.stacktrace?.frames?.some(frame => !!frame.instructionAddr)
  79. )
  80. }
  81. hasAppOnlyFrames={
  82. !!data.values?.some(
  83. value => !!value.stacktrace?.frames?.some(frame => frame.inApp !== true)
  84. )
  85. }
  86. hasNewestFirst={
  87. !!data.values?.some(value => (value.stacktrace?.frames ?? []).length > 1)
  88. }
  89. stackTraceNotFound={stackTraceNotFound}
  90. showPermalink
  91. wrapTitle={false}
  92. >
  93. {({raw, recentFirst, activeDisplayOptions}) =>
  94. stackTraceNotFound ? (
  95. <NoStackTraceMessage />
  96. ) : (
  97. <CrashContentException
  98. stackType={
  99. activeDisplayOptions.includes(DisplayOption.MINIFIED)
  100. ? STACK_TYPE.MINIFIED
  101. : STACK_TYPE.ORIGINAL
  102. }
  103. stackView={
  104. raw
  105. ? STACK_VIEW.RAW
  106. : activeDisplayOptions.includes(DisplayOption.FULL_STACK_TRACE)
  107. ? STACK_VIEW.FULL
  108. : STACK_VIEW.APP
  109. }
  110. projectId={projectId}
  111. newestFirst={recentFirst}
  112. event={event}
  113. platform={platform}
  114. values={data.values}
  115. groupingCurrentLevel={groupingCurrentLevel}
  116. hasHierarchicalGrouping={hasHierarchicalGrouping}
  117. />
  118. )
  119. }
  120. </TraceEventDataSection>
  121. );
  122. }
  123. export default Exception;
  124. const Title = styled('h3')`
  125. margin-bottom: 0;
  126. `;