Skip to content

Commit

Permalink
title parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin committed Mar 19, 2024
1 parent f364293 commit 058b012
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { SessionPlayerModal } from '../player/modal/SessionPlayerModal'
import { sessionPlayerModalLogic } from '../player/modal/sessionPlayerModalLogic'
import { sessionRecordingErrorsLogic } from './sessionRecordingErrorsLogic'

const MAX_TITLE_LENGTH = 75

export function SessionRecordingErrors(): JSX.Element {
const { openSessionPlayer } = useActions(sessionPlayerModalLogic)
const { errors, errorsLoading } = useValues(sessionRecordingErrorsLogic)
Expand Down Expand Up @@ -126,10 +128,13 @@ function isJSON(str: string): boolean {
}

function parseTitle(error: string): string {
let input
try {
const parsedError = JSON.parse(error)
return parsedError.error || error
input = parsedError.error || error
} catch {
return error
input = error
}

return input.split('\n')[0].trim().substring(0, MAX_TITLE_LENGTH)
}

0 comments on commit 058b012

Please sign in to comment.