@twin.org/api-models 0.0.1-next.33 → 0.0.1-next.34
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/dist/cjs/index.cjs +4 -5
- package/dist/esm/index.mjs +5 -6
- package/docs/changelog.md +7 -0
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -45,18 +45,17 @@ class HttpErrorHelper {
|
|
|
45
45
|
// types then set the http response code accordingly
|
|
46
46
|
const flattened = core.BaseError.flatten(error);
|
|
47
47
|
let httpStatusCode = web.HttpStatusCode.internalServerError;
|
|
48
|
-
if (flattened.some(e => core.BaseError.isErrorName(e, core.GuardError.CLASS_NAME))
|
|
48
|
+
if (flattened.some(e => core.BaseError.isErrorName(e, core.GuardError.CLASS_NAME)) ||
|
|
49
|
+
flattened.some(e => core.BaseError.isErrorName(e, core.ValidationError.CLASS_NAME))) {
|
|
49
50
|
httpStatusCode = web.HttpStatusCode.badRequest;
|
|
50
51
|
}
|
|
51
|
-
else if (flattened.some(e => core.BaseError.isErrorName(e, core.ConflictError.CLASS_NAME))
|
|
52
|
+
else if (flattened.some(e => core.BaseError.isErrorName(e, core.ConflictError.CLASS_NAME)) ||
|
|
53
|
+
flattened.some(e => core.BaseError.isErrorName(e, core.AlreadyExistsError.CLASS_NAME))) {
|
|
52
54
|
httpStatusCode = web.HttpStatusCode.conflict;
|
|
53
55
|
}
|
|
54
56
|
else if (flattened.some(e => core.BaseError.isErrorName(e, core.NotFoundError.CLASS_NAME))) {
|
|
55
57
|
httpStatusCode = web.HttpStatusCode.notFound;
|
|
56
58
|
}
|
|
57
|
-
else if (flattened.some(e => core.BaseError.isErrorName(e, core.AlreadyExistsError.CLASS_NAME))) {
|
|
58
|
-
httpStatusCode = web.HttpStatusCode.conflict;
|
|
59
|
-
}
|
|
60
59
|
else if (flattened.some(e => core.BaseError.isErrorName(e, core.UnauthorizedError.CLASS_NAME))) {
|
|
61
60
|
httpStatusCode = web.HttpStatusCode.unauthorized;
|
|
62
61
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Factory, BaseError, GuardError,
|
|
1
|
+
import { Factory, BaseError, GuardError, ValidationError, ConflictError, AlreadyExistsError, NotFoundError, UnauthorizedError, NotImplementedError, UnprocessableError, Is } from '@twin.org/core';
|
|
2
2
|
import { HttpStatusCode, MimeTypes, HeaderTypes } from '@twin.org/web';
|
|
3
3
|
|
|
4
4
|
// Copyright 2024 IOTA Stiftung.
|
|
@@ -43,18 +43,17 @@ class HttpErrorHelper {
|
|
|
43
43
|
// types then set the http response code accordingly
|
|
44
44
|
const flattened = BaseError.flatten(error);
|
|
45
45
|
let httpStatusCode = HttpStatusCode.internalServerError;
|
|
46
|
-
if (flattened.some(e => BaseError.isErrorName(e, GuardError.CLASS_NAME))
|
|
46
|
+
if (flattened.some(e => BaseError.isErrorName(e, GuardError.CLASS_NAME)) ||
|
|
47
|
+
flattened.some(e => BaseError.isErrorName(e, ValidationError.CLASS_NAME))) {
|
|
47
48
|
httpStatusCode = HttpStatusCode.badRequest;
|
|
48
49
|
}
|
|
49
|
-
else if (flattened.some(e => BaseError.isErrorName(e, ConflictError.CLASS_NAME))
|
|
50
|
+
else if (flattened.some(e => BaseError.isErrorName(e, ConflictError.CLASS_NAME)) ||
|
|
51
|
+
flattened.some(e => BaseError.isErrorName(e, AlreadyExistsError.CLASS_NAME))) {
|
|
50
52
|
httpStatusCode = HttpStatusCode.conflict;
|
|
51
53
|
}
|
|
52
54
|
else if (flattened.some(e => BaseError.isErrorName(e, NotFoundError.CLASS_NAME))) {
|
|
53
55
|
httpStatusCode = HttpStatusCode.notFound;
|
|
54
56
|
}
|
|
55
|
-
else if (flattened.some(e => BaseError.isErrorName(e, AlreadyExistsError.CLASS_NAME))) {
|
|
56
|
-
httpStatusCode = HttpStatusCode.conflict;
|
|
57
|
-
}
|
|
58
57
|
else if (flattened.some(e => BaseError.isErrorName(e, UnauthorizedError.CLASS_NAME))) {
|
|
59
58
|
httpStatusCode = HttpStatusCode.unauthorized;
|
|
60
59
|
}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @twin.org/api-models - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.1-next.34](https://github.com/twinfoundation/api/compare/api-models-v0.0.1-next.33...api-models-v0.0.1-next.34) (2025-05-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
|
|
9
|
+
|
|
3
10
|
## [0.0.1-next.33](https://github.com/twinfoundation/api/compare/api-models-v0.0.1-next.32...api-models-v0.0.1-next.33) (2025-04-17)
|
|
4
11
|
|
|
5
12
|
|