[js] add InvalidArgumentError

This commit is contained in:
方而静 2024-02-11 16:59:13 +08:00
parent 9135bc9c88
commit 55b7945dc1
Signed by: szTom
GPG Key ID: 072D999D60C6473C
3 changed files with 38 additions and 0 deletions

15
shared/apc/index.mjs Normal file
View File

@ -0,0 +1,15 @@
import { Buffer } from 'buffer';
export class AsyncProcedureCallEndpoint {
/**
* Constructs an AsyncProcedureCallEndpoint object.
* @param {any} input - stream of data sent by remote.
* @param {any} output - stream of data to send to remote.
*/
constructor(input, output) {
this.buf = Buffer();
input.ondata = () => {
};
}
};

11
shared/apc/package.json Normal file
View File

@ -0,0 +1,11 @@
{
"name": "@og/async-procedure-call",
"type": "module",
"main": "index.mjs",
"dependencies": {
"buffer": "^6.0.3",
"@og/error-utils": "file:../error-utils",
"@og/uuid": "file:../uuid",
"@og/binary-struct": "file:../bstruct"
}
}

View File

@ -9,3 +9,15 @@ export class VirtualMethodNotImplementedError extends Error {
super('virtual method not implemented.'); super('virtual method not implemented.');
} }
}; };
/**
* Represents an error that is thrown when called a function with invalid arguments.
* @class
* @extends {Error}
*/
export class InvalidArgumentError extends Error {
/** @constructor */
constructor(name, reason) {
super(`argument ${name} is invalid: ${reason}.`);
}
};