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

feat: add TimeoutError #5751

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
* can be used to handle cases where a process or task is terminated before completion.
*/
export class InterruptError extends Error {}

/**
* An error thrown when an action times out.
*/
export class TimeoutError extends Error {}
3 changes: 2 additions & 1 deletion yarn-project/foundation/src/fifo/memory_fifo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TimeoutError } from '../error/index.js';
import { createDebugLogger } from '../log/index.js';

/**
Expand Down Expand Up @@ -46,7 +47,7 @@ export class MemoryFifo<T> {
const index = this.waiting.findIndex(r => r === resolve);
if (index > -1) {
this.waiting.splice(index, 1);
const err = new Error('Timeout getting item from queue.');
const err = new TimeoutError('Timeout getting item from queue.');
reject(err);
}
}, timeout * 1000);
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * as bigintBuffer from './bigint-buffer/index.js';
export * as collection from './collection/index.js';
export * as committable from './committable/index.js';
export * as crypto from './crypto/index.js';
export * as errors from './errors/index.js';
export * as errors from './error/index.js';
export * as ethAddress from './eth-address/index.js';
export * as fields from './fields/index.js';
export * as fifo from './fifo/index.js';
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/sleep/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InterruptError } from '../errors/index.js';
import { InterruptError } from '../error/index.js';

/**
* InterruptibleSleep is a utility class that allows you to create an interruptible sleep function.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/sleep/sleep.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { jest } from '@jest/globals';

import { InterruptError } from '../errors/index.js';
import { InterruptError } from '../error/index.js';
import { InterruptibleSleep } from './index.js';

describe('InterruptibleSleep', () => {
Expand Down
Loading