Skip to content

Commit

Permalink
Merge pull request #1166 from nextcloud-libraries/enh/add-dedicated-e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
skjnldsv authored Jan 11, 2024
2 parents 9f68d65 + a73d1bf commit f69b6f1
Showing 1 changed file with 6 additions and 1 deletion.
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

0 comments on commit f69b6f1

Please sign in to comment.