Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve file structure
  • Loading branch information
Kateryna Kodonenko
Kateryna Kodonenko committed May 15, 2026
commit 4a482e90cc211bc02b0abaa866e2ee676341e6fc
8 changes: 2 additions & 6 deletions apps/studio/src/hooks/use-site-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'react';
import { useContentTabs } from 'src/hooks/use-content-tabs';
import { useIpcListener } from 'src/hooks/use-ipc-listener';
import { simplifyErrorForDisplay } from 'src/lib/error-formatting';
import { simplifyErrorForDisplay, simplifyErrorToFirstSentence } from 'src/lib/error-formatting';
import { getIpcApi } from 'src/lib/get-ipc-api';
import type { Blueprint } from 'src/stores/wpcom-api';

Expand Down Expand Up @@ -271,11 +271,7 @@ export function SiteDetailsProvider( { children }: SiteDetailsProviderProps ) {
message = __(
'The selected Blueprint failed to execute properly. This could be due to invalid PHP code, missing plugins, or other issues in the Blueprint file. Please check your Blueprint file and try again.'
);
// Show only the first sentence to keep the dialog concise.
// Full details are available via "Open Studio Logs".
const simplified = simplifyErrorForDisplay( error );
const firstSentence = simplified.message.match( /^[^.]+\./ );
errorToShow = firstSentence ? new Error( firstSentence[ 0 ] ) : simplified;
errorToShow = simplifyErrorToFirstSentence( error );
} else {
title = __( 'Failed to create site' );
message = __(
Expand Down
11 changes: 11 additions & 0 deletions apps/studio/src/lib/error-formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ export function simplifyErrorForDisplay( error: unknown ): Error {
}
return new Error( String( error ) );
}

/**
* Like `simplifyErrorForDisplay`, but also truncates to the first sentence.
* Useful when the first line is a long, detailed error message and the dialog
* should stay concise (e.g. blueprint errors). Full details are available via logs.
*/
export function simplifyErrorToFirstSentence( error: unknown ): Error {
const simplified = simplifyErrorForDisplay( error );
const firstSentence = simplified.message.match( /^[^.]+\./ );
return firstSentence ? new Error( firstSentence[ 0 ] ) : simplified;
}