Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(FilePickerBuilder): Change error thrown when FilePicker is closed #1166

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/filepicker-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ export enum FilePickerType {
Custom = 5,
}

/**
* Error that is thrown in the rejected promise when the FilePicker was closed
*/
export class FilePickerClosed extends Error {}

export class FilePicker<IsMultiSelect extends boolean> {

private title: string
Expand Down Expand Up @@ -91,7 +96,7 @@ export class FilePicker<IsMultiSelect extends boolean> {
}, (...rest: unknown[]) => {
const [nodes] = rest as [nodes: Node[]]
if (!Array.isArray(nodes) || nodes.length === 0) {
reject(new Error('FilePicker: No nodes selected'))
reject(new FilePickerClosed('FilePicker: No nodes selected'))
} else {
if (this.multiSelect) {
resolve((nodes as Node[]).map((node) => node.path) as (IsMultiSelect extends true ? string[] : string))
Expand Down