Skip to content

Commit

Permalink
Merge pull request #1 from StatesTitle/mdoliner-st/Add_a_StructLike_c…
Browse files Browse the repository at this point in the history
…lass_that_extends_Error

I'm merging this change into the all_states_title_changes branch. For the full PR description see [the PR for merging this change into Credit Karma's master branch](creditkarma#132).
  • Loading branch information
markdoliner-doma authored Sep 1, 2020
2 parents 5787abd + 50c661b commit 8ea3898
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/thrift-server-core/src/main/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends StructLike> {
new (args?: any): T
read(input: TProtocol): T
Expand Down

0 comments on commit 8ea3898

Please sign in to comment.