Skip to content

Commit

Permalink
refactor(app/error/builder): add docs on builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ikr4-m committed Mar 26, 2024
1 parent 1c1a875 commit fff4794
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/App/Error/ErrorBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,52 @@ export default class ErrorBuilder<T extends {}> implements IErrorBuilder<T> {
return this;
}

/**
* Set additional fields on error query
*/
public setKind<D extends T>(data: D): ErrorBuilder<D> {
return this.setProps("kind", data) as unknown as ErrorBuilder<D>;
}

/**
* Set instance or path where error raised on error query
*/
public setInstance(instance: string): this {
return this.setProps("instance", instance);
}

/**
* Set code error type on error query
*/
public setMDNCodeType(code: StatusCode): this {
return this.setProps("type", `https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/${code}`);
}

/**
* Set type of error URI on error query
*/
public setType(type: string): this {
return this.setProps("type", type);
}

/**
* Set the title on error query
*/
public setTitle(title: string): this {
return this.setProps("title", title);
}

/**
* Set the detail on error query
*/
public setDetail(detail: string): this {
return this.setProps("detail", detail);
}

public build(): any {
/**
* Generate the error query
*/
public build(): IErrorBuilder<T> {
const data: IErrorBuilder<T> = {
type: this.type,
title: this.title,
Expand Down

0 comments on commit fff4794

Please sign in to comment.