Skip to content

Commit

Permalink
Renamed ApiError.FileError to ApiError.OnPath
Browse files Browse the repository at this point in the history
  • Loading branch information
james-pre committed Mar 5, 2024
1 parent 91c29c6 commit 97c0917
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/ApiError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,36 +108,36 @@ export class ApiError extends Error implements NodeJS.ErrnoException {
return err;
}

public static FileError(code: ErrorCode, path: string): ApiError {
public static OnPath(code: ErrorCode, path: string): ApiError {
return new ApiError(code, ErrorStrings[code], path);
}

public static EACCES(path: string): ApiError {
return this.FileError(ErrorCode.EACCES, path);
return this.OnPath(ErrorCode.EACCES, path);
}

public static ENOENT(path: string): ApiError {
return this.FileError(ErrorCode.ENOENT, path);
return this.OnPath(ErrorCode.ENOENT, path);
}

public static EEXIST(path: string): ApiError {
return this.FileError(ErrorCode.EEXIST, path);
return this.OnPath(ErrorCode.EEXIST, path);
}

public static EISDIR(path: string): ApiError {
return this.FileError(ErrorCode.EISDIR, path);
return this.OnPath(ErrorCode.EISDIR, path);
}

public static ENOTDIR(path: string): ApiError {
return this.FileError(ErrorCode.ENOTDIR, path);
return this.OnPath(ErrorCode.ENOTDIR, path);
}

public static EPERM(path: string): ApiError {
return this.FileError(ErrorCode.EPERM, path);
return this.OnPath(ErrorCode.EPERM, path);
}

public static ENOTEMPTY(path: string): ApiError {
return this.FileError(ErrorCode.ENOTEMPTY, path);
return this.OnPath(ErrorCode.ENOTEMPTY, path);
}

public code: string;
Expand Down
1 change: 0 additions & 1 deletion test/tests/chmod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const asyncMode = 0o777;
const modeSync = 0o644;

describe('chmod tests', () => {

it('should change file mode using chmod', async () => {
const file1 = path.join(fixturesDir, 'a.js');

Expand Down
11 changes: 5 additions & 6 deletions test/tests/error-messages.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { backends, fs, configure, fixturesDir } from '../common';
import { fs, fixturesDir } from '../common';
import * as path from 'path';

import type { ApiError } from '../../src/ApiError';
Expand Down Expand Up @@ -31,11 +31,10 @@ const expectSyncError = (fn: (...args) => unknown, p: string, ...args) => {
return error;
};

describe.each(backends)('%s Error tests', (name, options) => {
const configured = configure(options);
describe('Error tests', () => {

it('should handle async operations with error', async () => {
await configured;

const fn = path.join(fixturesDir, 'non-existent');

await expectError(fs.promises.stat, fn);
Expand All @@ -61,8 +60,8 @@ describe.each(backends)('%s Error tests', (name, options) => {

// Sync operations
if (fs.getMount('/').metadata.synchronous) {
it('should handle sync operations with error', async () => {
await configured;
it('should handle sync operations with error', () => {

const fn = path.join(fixturesDir, 'non-existent');
const existingFile = path.join(fixturesDir, 'exit.js');

Expand Down
1 change: 0 additions & 1 deletion test/tests/symlink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { backends, fs, fixturesDir } from '../common';
import * as path from 'path';

describe.each(backends)('%s Link and Symlink Test', (name, options) => {

it('should create and read symbolic link', async () => {
const linkData = path.join(fixturesDir, '/cycles/root.js');
const linkPath = 'symlink1.js';
Expand Down

0 comments on commit 97c0917

Please sign in to comment.