File size: 1,325 Bytes
26abd99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import { Uri } from 'vscode';

export class TestFileSystemError extends Error {
  static FileExists(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('FileExists', messageOrUri);
  }
  static FileNotFound(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('FileNotFound', messageOrUri);
  }
  static FileNotADirectory(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('FileNotADirectory', messageOrUri);
  }
  static FileIsADirectory(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('FileIsADirectory', messageOrUri);
  }
  static NoPermissions(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('NoPermissions', messageOrUri);
  }
  static Unavailable(messageOrUri?: string | Uri): TestFileSystemError {
    return new TestFileSystemError('Unavailable', messageOrUri);
  }

  constructor(
    readonly code: string,
    uriOrMessage?: string | Uri,
  ) {
    uriOrMessage ??= 'Unknown';
    const message =
      typeof uriOrMessage === 'string' ? uriOrMessage : uriOrMessage.toString();
    super(`${code}: ${message}`);

    this.name = code;
  }
}