@gitbeaker/rest 39.27.0 → 39.27.1
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 +16 -7
- package/dist/index.js +3 -3
- package/dist/index.mjs +4 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -339,17 +339,26 @@ const api = new Gitlab({
|
|
|
339
339
|
|
|
340
340
|
Request errors are returned back within a plain Error instance, using the cause to hold the original response and a text description of the error pulled from the response's error or message fields if JSON, or its plain text value:
|
|
341
341
|
|
|
342
|
-
```
|
|
343
|
-
Error
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
342
|
+
```ts
|
|
343
|
+
class GitbeakerError extends Error {
|
|
344
|
+
constructor(
|
|
345
|
+
message: string,
|
|
346
|
+
options?: {
|
|
347
|
+
cause: {
|
|
348
|
+
description: string;
|
|
349
|
+
request: Request;
|
|
350
|
+
response: Response;
|
|
351
|
+
};
|
|
352
|
+
},
|
|
353
|
+
) {
|
|
354
|
+
super(message, options);
|
|
355
|
+
this.name = 'GitbeakerError';
|
|
349
356
|
}
|
|
350
357
|
}
|
|
351
358
|
```
|
|
352
359
|
|
|
360
|
+
Note, the message is assigned to the Response's `statusText`, and the [Request](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#request) and [Response](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#response) types are from the NodeJS API.
|
|
361
|
+
|
|
353
362
|
## Examples
|
|
354
363
|
|
|
355
364
|
Once you have your library instantiated, you can utilize many of the API's functionality:
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ async function throwFailedRequestError(request, response) {
|
|
|
72
72
|
} else {
|
|
73
73
|
description = content;
|
|
74
74
|
}
|
|
75
|
-
throw new
|
|
75
|
+
throw new requesterUtils.GitbeakerRequestError(response.statusText, {
|
|
76
76
|
cause: {
|
|
77
77
|
description,
|
|
78
78
|
request,
|
|
@@ -101,7 +101,7 @@ async function defaultRequestHandler(endpoint, options) {
|
|
|
101
101
|
await endpointRateLimit();
|
|
102
102
|
const response = await fetch(request).catch((e) => {
|
|
103
103
|
if (e.name === "TimeoutError" || e.name === "AbortError") {
|
|
104
|
-
throw new
|
|
104
|
+
throw new requesterUtils.GitbeakerTimeoutError("Query timeout was reached");
|
|
105
105
|
}
|
|
106
106
|
throw e;
|
|
107
107
|
});
|
|
@@ -112,7 +112,7 @@ async function defaultRequestHandler(endpoint, options) {
|
|
|
112
112
|
await delay(2 ** i * 0.25);
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
-
throw new
|
|
115
|
+
throw new requesterUtils.GitbeakerRetryError(
|
|
116
116
|
`Could not successfully complete this request due to Error 429. Check the applicable rate limits for this endpoint.`
|
|
117
117
|
);
|
|
118
118
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Resources from '@gitbeaker/core';
|
|
2
|
-
import { createRequesterFn, presetResourceArguments, getMatchingRateLimiter } from '@gitbeaker/requester-utils';
|
|
2
|
+
import { createRequesterFn, presetResourceArguments, getMatchingRateLimiter, GitbeakerTimeoutError, GitbeakerRetryError, GitbeakerRequestError } from '@gitbeaker/requester-utils';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
5
|
async function defaultOptionsHandler(resourceOptions, requestOptions) {
|
|
@@ -50,7 +50,7 @@ async function throwFailedRequestError(request, response) {
|
|
|
50
50
|
} else {
|
|
51
51
|
description = content;
|
|
52
52
|
}
|
|
53
|
-
throw new
|
|
53
|
+
throw new GitbeakerRequestError(response.statusText, {
|
|
54
54
|
cause: {
|
|
55
55
|
description,
|
|
56
56
|
request,
|
|
@@ -79,7 +79,7 @@ async function defaultRequestHandler(endpoint, options) {
|
|
|
79
79
|
await endpointRateLimit();
|
|
80
80
|
const response = await fetch(request).catch((e) => {
|
|
81
81
|
if (e.name === "TimeoutError" || e.name === "AbortError") {
|
|
82
|
-
throw new
|
|
82
|
+
throw new GitbeakerTimeoutError("Query timeout was reached");
|
|
83
83
|
}
|
|
84
84
|
throw e;
|
|
85
85
|
});
|
|
@@ -90,7 +90,7 @@ async function defaultRequestHandler(endpoint, options) {
|
|
|
90
90
|
await delay(2 ** i * 0.25);
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
throw new
|
|
93
|
+
throw new GitbeakerRetryError(
|
|
94
94
|
`Could not successfully complete this request due to Error 429. Check the applicable rate limits for this endpoint.`
|
|
95
95
|
);
|
|
96
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitbeaker/rest",
|
|
3
|
-
"version": "39.27.
|
|
3
|
+
"version": "39.27.1",
|
|
4
4
|
"description": "Cross Platform implementation of the GitLab API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"release": "auto shipit"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@gitbeaker/core": "^39.27.
|
|
60
|
-
"@gitbeaker/requester-utils": "^39.27.
|
|
59
|
+
"@gitbeaker/core": "^39.27.1",
|
|
60
|
+
"@gitbeaker/requester-utils": "^39.27.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@playwright/test": "^1.40.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"tsup": "^8.0.1",
|
|
66
66
|
"typescript": "^5.3.3"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "4de10dcc0b1ecb50c47d8d5088b9dd28ebf7ab92"
|
|
69
69
|
}
|