Skip to content

Commit 17d1f18

Browse files
committed
fix: guard optional message field in showMessageBox catch handler
Add optional chaining to options.message?.length in the catch handler and update the messageLength schema to NullOr(Schema.Number) for consistency with titleLength and detailLength. Previously, if message was omitted from MessageBoxOptions and the dialog promise rejected, accessing .length on undefined would throw a TypeError inside catch, bypassing the typed ElectronDialogShowMessageBoxError.
1 parent 513653f commit 17d1f18

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

apps/desktop/src/electron/ElectronDialog.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class ElectronDialogShowMessageBoxError extends Schema.TaggedErrorClass<E
4242
{
4343
type: Schema.NullOr(Schema.Literals(["none", "info", "error", "question", "warning"])),
4444
titleLength: Schema.NullOr(Schema.Number),
45-
messageLength: Schema.Number,
45+
messageLength: Schema.NullOr(Schema.Number),
4646
detailLength: Schema.NullOr(Schema.Number),
4747
buttonCount: Schema.Number,
4848
cause: Schema.Defect(),
@@ -177,7 +177,7 @@ export const make = ElectronDialog.of({
177177
new ElectronDialogShowMessageBoxError({
178178
type: options.type ?? null,
179179
titleLength: options.title?.length ?? null,
180-
messageLength: options.message.length,
180+
messageLength: options.message?.length ?? null,
181181
detailLength: options.detail?.length ?? null,
182182
buttonCount: options.buttons?.length ?? 0,
183183
cause,

0 commit comments

Comments
 (0)