getStacktraceBody.tsx 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. import rawStacktraceContent from 'sentry/components/events/interfaces/crashContent/stackTrace/rawContent';
  2. import {Event} from 'sentry/types/event';
  3. export default function getStacktraceBody(event: Event) {
  4. if (!event || !event.entries) {
  5. return [];
  6. }
  7. // TODO(billyvg): This only accounts for the first exception, will need navigation to be able to
  8. // diff multiple exceptions
  9. //
  10. // See: https://github.com/getsentry/sentry/issues/6055
  11. const exc = event.entries.find(({type}) => type === 'exception');
  12. if (!exc) {
  13. // Look for a message if not an exception
  14. const msg = event.entries.find(({type}) => type === 'message');
  15. if (!msg) {
  16. return [];
  17. }
  18. return msg?.data?.formatted && [msg.data.formatted];
  19. }
  20. if (!exc.data) {
  21. return [];
  22. }
  23. // TODO(ts): This should be verified when EntryData has the correct type
  24. return exc.data.values
  25. .filter(value => !!value.stacktrace)
  26. .map(value => rawStacktraceContent(value.stacktrace, event.platform, value))
  27. .reduce((acc, value) => acc.concat(value), []);
  28. }