diff --git a/packages/thrift-server-core/src/main/types.ts b/packages/thrift-server-core/src/main/types.ts index e10aa291..b2efb530 100644 --- a/packages/thrift-server-core/src/main/types.ts +++ b/packages/thrift-server-core/src/main/types.ts @@ -86,6 +86,22 @@ export abstract class StructLike implements IStructLike { public abstract write(output: TProtocol): void } +/** + * Like `StructLike` but extends `Error`. Exception classes extend this. + */ +export abstract class ErrorStructLike extends Error implements IStructLike { + public readonly name: string + public readonly _annotations: IThriftAnnotations = {} + public readonly _fieldAnnotations: IFieldAnnotations = {} + + constructor() { + super() + this.name = this.constructor.name + } + + public abstract write(output: TProtocol): void +} + export interface IStructConstructor { new (args?: any): T read(input: TProtocol): T