exceptionV2.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 CrashContentException from './crashContent/exception';
  8. import NoStackTraceMessage from './noStackTraceMessage';
  9. import {isStacktraceNewestFirst} from './utils';
  10. type Props = {
  11. data: ExceptionType;
  12. event: Event;
  13. hasHierarchicalGrouping: boolean;
  14. projectId: Project['id'];
  15. type: string;
  16. groupingCurrentLevel?: Group['metadata']['current_level'];
  17. hideGuide?: boolean;
  18. };
  19. function Exception({
  20. event,
  21. type,
  22. data,
  23. projectId,
  24. hasHierarchicalGrouping,
  25. groupingCurrentLevel,
  26. }: Props) {
  27. const eventHasThreads = !!event.entries.some(entry => entry.type === 'threads');
  28. /* in case there are threads in the event data, we don't render the
  29. exception block. Instead the exception is contained within the
  30. thread interface. */
  31. if (eventHasThreads) {
  32. return null;
  33. }
  34. function getPlatform(): PlatformType {
  35. const dataValue = data.values?.find(
  36. value => !!value.stacktrace?.frames?.some(frame => !!frame.platform)
  37. );
  38. if (dataValue) {
  39. const framePlatform = dataValue.stacktrace?.frames?.find(frame => !!frame.platform);
  40. if (framePlatform?.platform) {
  41. return framePlatform.platform;
  42. }
  43. }
  44. return event.platform ?? 'other';
  45. }
  46. const stackTraceNotFound = !(data.values ?? []).length;
  47. const platform = getPlatform();
  48. return (
  49. <TraceEventDataSection
  50. title={<Title>{t('Exception')}</Title>}
  51. type={type}
  52. stackType={STACK_TYPE.ORIGINAL}
  53. projectId={projectId}
  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. showPermalink
  90. wrapTitle={false}
  91. >
  92. {({recentFirst, display, fullStackTrace}) =>
  93. stackTraceNotFound ? (
  94. <NoStackTraceMessage />
  95. ) : (
  96. <CrashContentException
  97. stackType={
  98. display.includes('minified') ? STACK_TYPE.MINIFIED : STACK_TYPE.ORIGINAL
  99. }
  100. stackView={
  101. display.includes('raw-stack-trace')
  102. ? STACK_VIEW.RAW
  103. : fullStackTrace
  104. ? STACK_VIEW.FULL
  105. : STACK_VIEW.APP
  106. }
  107. projectId={projectId}
  108. newestFirst={recentFirst}
  109. event={event}
  110. platform={platform}
  111. values={data.values}
  112. groupingCurrentLevel={groupingCurrentLevel}
  113. hasHierarchicalGrouping={hasHierarchicalGrouping}
  114. />
  115. )
  116. }
  117. </TraceEventDataSection>
  118. );
  119. }
  120. export default Exception;
  121. const Title = styled('h3')`
  122. margin-bottom: 0;
  123. `;