Skip to content

Commit

Permalink
[#169] added ErrorResponse type used as "reject" reason in order to…
Browse files Browse the repository at this point in the history
… access status code together with body

* fixed that only JSON was assumed as body - fall back to any value if error response was not JSON
* updated dependencies to its minor version updates
* update to upcoming Ditto JS client version 3.0.0

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Sep 7, 2022
1 parent 5eb16b7 commit 72b44b3
Show file tree
Hide file tree
Showing 12 changed files with 5,342 additions and 6,069 deletions.
11 changes: 11 additions & 0 deletions javascript/CHANGELOG.md
@@ -1,6 +1,17 @@
# Changelog
All notable changes to the Ditto JavaScript client will be documented in this file.

## [3.0.0] - 2022-09-xx

### Updated dependencies
TODO text

### \#169 Improved error handling for HTTP rejections
TODO text

### \#193 Preserve headers when responding to messages
TODO text

## [2.4.0] - 2022-04-14

### No changes
Expand Down
2 changes: 1 addition & 1 deletion javascript/lerna.json
Expand Up @@ -16,5 +16,5 @@
]
}
},
"version": "2.4.0"
"version": "3.0.0"
}
445 changes: 244 additions & 201 deletions javascript/lib/api/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions javascript/lib/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@eclipse-ditto/ditto-javascript-client-api",
"version": "2.4.0",
"version": "3.0.0",
"description": "API interfaces for implementing TypeScript clients for Eclipse Ditto",
"author": "Eclipse Ditto committers <ditto-dev@eclipse.org>",
"repository": "https://github.com/eclipse/ditto-clients",
Expand All @@ -25,7 +25,7 @@
"tslint": "^5.18.x",
"tslint-config-airbnb": "^5.11.1",
"tslint-sonarts": "^1.8.0",
"typescript": "^3.4.3"
"typescript": "^3.9.10"
},
"scripts": {
"build": "npm run build:tsc && npm run build:barrels",
Expand Down
31 changes: 31 additions & 0 deletions javascript/lib/api/src/model/response.ts
Expand Up @@ -26,6 +26,18 @@ export interface GenericResponse {
headers: Map<string, string>;
}

/**
* A generic server response to a request.
*/
export interface ErrorResponse {
/** The status code of the error response. */
status: number;
/** The body of the error response. */
body: any;
/** The headers of the error response inside a map. */
headers: Map<string, string>;
}

export class PutResponse<T> implements GenericResponse {
public constructor(private readonly _value: T | null,
private readonly _status: number,
Expand Down Expand Up @@ -53,6 +65,25 @@ export class PutResponse<T> implements GenericResponse {
}
}

export class BasicErrorResponse<T> implements ErrorResponse {
public constructor(private readonly _value: T | null,
private readonly _status: number,
private readonly _headers: Map<string, string>) {
}

get body(): T | null {
return this._value;
}

get status(): number {
return this._status;
}

get headers(): Map<string, string> {
return this._headers;
}
}


/**
* Representation of a response ot a search request
Expand Down

0 comments on commit 72b44b3

Please sign in to comment.