-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added extensions to problem details (#32)
* Added extensions to problem details * feat: made detail/instance optional (as per RFC) * chore: updated yarn lockfile, made 'husky install' part of prep script
- Loading branch information
1 parent
a8e19e5
commit 96ac162
Showing
4 changed files
with
6,059 additions
and
6,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,34 @@ | ||
import {HttpError} from './HttpError'; | ||
|
||
export type ProblemDetailsArgs = { | ||
detail: string; | ||
instance: string; | ||
detail?: string; | ||
instance?: string; | ||
statusCode: number; | ||
title: string; | ||
type: string; | ||
extensions?: { | ||
[k: string]: unknown; | ||
}; | ||
}; | ||
|
||
export class ProblemDetailsError extends HttpError { | ||
public detail: string; | ||
public type: string; | ||
public instance: string; | ||
public title: string; | ||
public detail?: string; | ||
public instance?: string; | ||
public extensions?: { | ||
[k: string]: unknown; | ||
}; | ||
|
||
constructor(args: ProblemDetailsArgs) { | ||
const {detail, instance, statusCode, title, type} = args; | ||
const {detail, instance, statusCode, title, type, extensions} = args; | ||
|
||
super(detail, statusCode); | ||
super(detail ?? title, statusCode); | ||
|
||
this.detail = detail; | ||
this.type = type; | ||
this.instance = instance; | ||
this.title = title; | ||
this.extensions = extensions ?? {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.