@trayio/cdk-dsl 3.9.0 → 3.9.2-unstable
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/README.md +30 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -857,3 +857,33 @@ export const myOperationHandler =
|
|
|
857
857
|
)
|
|
858
858
|
);
|
|
859
859
|
```
|
|
860
|
+
|
|
861
|
+
## Error Handling
|
|
862
|
+
|
|
863
|
+
You could use `withErrorHandling()` on the `response` to display custom error messages to the users.
|
|
864
|
+
|
|
865
|
+
```typescript
|
|
866
|
+
handler.usingHttp((http) =>
|
|
867
|
+
http
|
|
868
|
+
.get('<url>')
|
|
869
|
+
.handleRequest((ctx, input, request) =>
|
|
870
|
+
request.withBearerToken(ctx.auth!.user.access_token).withoutBody()
|
|
871
|
+
)
|
|
872
|
+
.handleResponse((ctx, input, response) =>
|
|
873
|
+
response
|
|
874
|
+
.withErrorHandling(() => {
|
|
875
|
+
const status = response.getStatusCode();
|
|
876
|
+
|
|
877
|
+
if (status === 404) {
|
|
878
|
+
return OperationHandlerResult.failure(
|
|
879
|
+
OperationHandlerError.userInputError('post not found')
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
return OperationHandlerResult.failure(
|
|
883
|
+
OperationHandlerError.apiError(`api error: ${status}`)
|
|
884
|
+
);
|
|
885
|
+
})
|
|
886
|
+
.parseWithBodyAsJson()
|
|
887
|
+
)
|
|
888
|
+
);
|
|
889
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-dsl",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2-unstable",
|
|
4
4
|
"description": "A DSL for connector development",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "3.9.
|
|
17
|
+
"@trayio/commons": "3.9.2-unstable"
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|