objective-http 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"objective-http","version":"1.2.5","description":"Proxy classes for creating a http server","keywords":["web","web-server","http","http-server","oop"],"author":{"name":"volatilization","email":"volatilization@yandex.ru"},"repository":{"url":"git+https://github.com/volatilization/objective-http.git"},"license":"LGPL-3.0-only","main":"src/js/index.js"}
1
+ {"name":"objective-http","version":"1.2.6","description":"Proxy classes for creating a http server","keywords":["web","web-server","http","http-server","oop"],"author":{"name":"volatilization","email":"volatilization@yandex.ru"},"repository":{"url":"git+https://github.com/volatilization/objective-http.git"},"license":"LGPL-3.0-only","main":"src/js/index.js"}
@@ -18,6 +18,13 @@ module.exports = class LoggedEndpoint {
18
18
  async handle(request) {
19
19
  this.#logger.debug(`HttpEndpoint's handling [${request.route().method}] ${request.route().path}`);
20
20
 
21
- return await this.#origin.handle(request);
21
+ try {
22
+ return await this.#origin.handle(request);
23
+
24
+ } catch (e) {
25
+ this.#logger.error(`HttpEndpoint's handling [${request.route().method}] ${request.route().path} error: ${e.message}`, e);
26
+
27
+ throw e;
28
+ }
22
29
  }
23
30
  }
@@ -16,7 +16,14 @@ module.exports = class LoggedInputRequest {
16
16
  async flush() {
17
17
  this.#logger.debug(`HttpRequest: [${this.#inputStream.method}] ${this.#inputStream.url} ${JSON.stringify(this.#inputStream.headers)}`);
18
18
 
19
- return new LoggedInputRequest(await this.#origin.flush(), this.#logger);
19
+ try {
20
+ return new LoggedInputRequest(await this.#origin.flush(), this.#logger);
21
+
22
+ } catch (e) {
23
+ this.#logger.error(`HttpRequest: [${this.#inputStream.method}] ${this.#inputStream.url} error: ${e.message}`, e);
24
+
25
+ throw e;
26
+ }
20
27
  }
21
28
 
22
29
  route() {
@@ -16,10 +16,21 @@ module.exports = class LoggedOutputResponse {
16
16
  }
17
17
 
18
18
  flush() {
19
- const outputStream = this.#origin.flush();
19
+ const outputStream = this.#loggedFlush();
20
20
 
21
21
  this.#logger.debug(`HttpResponse: [${outputStream.req.method}] ${outputStream.req.url} - ${outputStream.statusCode}`);
22
22
 
23
23
  return outputStream;
24
24
  }
25
+
26
+ #loggedFlush() {
27
+ try {
28
+ return this.#origin.flush();
29
+
30
+ } catch (e) {
31
+ this.#logger.error(`HttpResponse error: ${e.message}`, e);
32
+
33
+ throw e;
34
+ }
35
+ }
25
36
  }