11import * as fs from 'node:fs' ;
22
3- import type { FileSystemAdapter , Pattern } from './types' ;
3+ import type { ErrnoException , FileSystemAdapter , Pattern } from './types' ;
44
55export const DEFAULT_FILE_SYSTEM_ADAPTER : FileSystemAdapter = {
66 lstat : fs . lstat ,
@@ -125,6 +125,13 @@ export interface Options {
125125 * @default false
126126 */
127127 suppressErrors ?: boolean ;
128+ /**
129+ * Callback for user-defined error handling. Ignored if
130+ * `suppressErrors` is `true`. Return `true` to suppress an error,
131+ * `false` to throw it.
132+ *
133+ */
134+ errorHandler ?: ( error : Error ) => boolean ;
128135 /**
129136 * Throw an error when symbolic link is broken if `true` or safely
130137 * return `lstat` call if `false`.
@@ -166,6 +173,7 @@ export default class Settings {
166173 public readonly onlyFiles : boolean ;
167174 public readonly stats : boolean ;
168175 public readonly suppressErrors : boolean ;
176+ public readonly errorHandler : ( ( error : ErrnoException ) => boolean ) | undefined ;
169177 public readonly throwErrorOnBrokenSymbolicLink : boolean ;
170178 public readonly unique : boolean ;
171179 public readonly signal ?: AbortSignal ;
@@ -190,7 +198,8 @@ export default class Settings {
190198 this . onlyFiles = options . onlyFiles ?? true ;
191199 this . stats = options . stats ?? false ;
192200 this . suppressErrors = options . suppressErrors ?? false ;
193- this . throwErrorOnBrokenSymbolicLink = options . throwErrorOnBrokenSymbolicLink ?? false ;
201+ this . errorHandler = options . errorHandler ?? undefined ;
202+ this . throwErrorOnBrokenSymbolicLink = options . throwErrorOnBrokenSymbolicLink ?? false ;
194203 this . unique = options . unique ?? true ;
195204 this . signal = options . signal ;
196205
0 commit comments