fix: improve question handling in chat

Updates question card behavior
Improves localized question text
Covers session question actions with tests
This commit is contained in:
Bohdan Triapitsyn
2026-06-03 14:51:17 +03:00
parent a0b22c9960
commit 2163c2e3f7
12 changed files with 208 additions and 22 deletions
+6 -2
View File
@@ -57,7 +57,9 @@ type SdkResult<T> = {
function unwrapSdkData<T>(result: SdkResult<T>, operation: string): T {
if (result.error) {
const status = result.response?.status;
throw new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`);
const error = new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`) as Error & { status?: number };
if (status !== undefined) error.status = status;
throw error;
}
if (result.data === undefined || result.data === null) {
throw new Error(`${operation} failed: empty response`);
@@ -68,7 +70,9 @@ function unwrapSdkData<T>(result: SdkResult<T>, operation: string): T {
function unwrapSdkOptional<T>(result: SdkResult<T>, operation: string): T | undefined {
if (result.error) {
const status = result.response?.status;
throw new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`);
const error = new Error(`${operation} failed${status ? ` (${status})` : ""}: ${formatSdkError(result.error)}`) as Error & { status?: number };
if (status !== undefined) error.status = status;
throw error;
}
return result.data;
}