Skip to content

Commit f9248ea

Browse files
author
williamd5
authored
Merge pull request #32 from cloudnode-pro/31-add-throws-definitions-for-new-page-methods
Add missing throws definitions
2 parents 29efff0 + 0405bb8 commit f9248ea

File tree

7 files changed

+28
-8
lines changed

7 files changed

+28
-8
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Get another page of paginated results
129129
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get a different page of.
130130
- `page` <code>[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)</code> Page to get.
131131
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The new page or null if the page is out of bounds
132-
132+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
133133

134134
<a name="cloudnodegetnextpagetresponse"></a>
135135

@@ -139,7 +139,7 @@ Get next page of paginated results
139139

140140
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get the next page of.
141141
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The next page or null if this is the last page
142-
142+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
143143

144144
<a name="cloudnodegetpreviouspagetresponse"></a>
145145

@@ -149,7 +149,7 @@ Get previous page of paginated results
149149

150150
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get the previous page of.
151151
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>> | [null](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/null)></code> The previous page or null if this is the first page
152-
152+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
153153

154154
<a name="cloudnodegetallpagestresponse"></a>
155155

@@ -160,7 +160,7 @@ Get all other pages of paginated results and return the complete data
160160
161161
- `response` <code>[Cloudnode.ApiResponse](#class-cloudnodeapiresponset)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> Response to get all pages of.
162162
- Returns: <code>[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[Cloudnode.PaginatedData](#interface-cloudnodepaginateddatat)&lt;T>></code> All of the data in 1 page
163-
163+
- Throws: <code>[Cloudnode.Error](#interface-cloudnodeerror)</code> Error returned by the API
164164

165165
<a name="cloudnodenewslettergetid"></a>
166166

browser/Cloudnode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Cloudnode {
8484
* @param response Response to get a different page of
8585
* @param page Page to get
8686
* @returns The new page or null if the page is out of bounds
87+
* @throws {Cloudnode.Error} Error returned by the API
8788
*/
8889
async getPage(response, page) {
8990
if (page * response.limit > response.total || page < 1)
@@ -96,6 +97,7 @@ class Cloudnode {
9697
* Get next page of paginated results
9798
* @param response Response to get the next page of
9899
* @returns The next page or null if this is the last page
100+
* @throws {Cloudnode.Error} Error returned by the API
99101
*/
100102
async getNextPage(response) {
101103
return await this.getPage(response, response.page + 1);
@@ -104,6 +106,7 @@ class Cloudnode {
104106
* Get previous page of paginated results
105107
* @param response Response to get the previous page of
106108
* @returns The previous page or null if this is the first page
109+
* @throws {Cloudnode.Error} Error returned by the API
107110
*/
108111
async getPreviousPage(response) {
109112
return await this.getPage(response, response.page - 1);
@@ -113,6 +116,7 @@ class Cloudnode {
113116
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
114117
* @param response Response to get all pages of
115118
* @returns All of the data in 1 page
119+
* @throws {Cloudnode.Error} Error returned by the API
116120
*/
117121
async getAllPages(response) {
118122
const pages = new Array(Math.ceil(response.total / response.limit)).fill(null);

gen/docs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,25 @@ export function generateDocSchema (schema: Schema, config: Config, pkg: Package)
7777
], {
7878
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
7979
description: "The new page or null if the page is out of bounds"
80-
}, []));
80+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
8181
always.push(new DocSchema.Method(`${config.name}.getNextPage<T>`, "Get next page of paginated results", [
8282
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get the next page of", true)
8383
], {
8484
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
8585
description: "The next page or null if this is the last page"
86-
}, []));
86+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
8787
always.push(new DocSchema.Method(`${config.name}.getPreviousPage<T>`, "Get previous page of paginated results", [
8888
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get the previous page of", true)
8989
], {
9090
type: `Promise<${config.name}.ApiResponse<${config.name}.PaginatedData<T>> | null>`,
9191
description: "The previous page or null if this is the first page"
92-
}, []));
92+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
9393
always.push(new DocSchema.Method(`${config.name}.getAllPages<T>`, "Get all other pages of paginated results and return the complete data\n> **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.", [
9494
new DocSchema.Parameter("response", `${config.name}.ApiResponse<${config.name}.PaginatedData<T>>`, "Response to get all pages of", true)
9595
], {
9696
type: `Promise<${config.name}.PaginatedData<T>>`,
9797
description: "All of the data in 1 page"
98-
}, []));
98+
}, [{type: `${config.name}.Error`, description: "Error returned by the API"}]));
9999
mainClass.properties.unshift(...always);
100100
mainNamespace.properties.sort((a, b) => a.displayName.localeCompare(b.displayName));
101101

gen/templates/main.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class {{config.name}} {
8686
* @param response Response to get a different page of
8787
* @param page Page to get
8888
* @returns The new page or null if the page is out of bounds
89+
* @throws {Cloudnode.Error} Error returned by the API
8990
*/
9091
async getPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>, page: number): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
9192
if (page * response.limit > response.total || page < 1) return null;
@@ -98,6 +99,7 @@ class {{config.name}} {
9899
* Get next page of paginated results
99100
* @param response Response to get the next page of
100101
* @returns The next page or null if this is the last page
102+
* @throws {Cloudnode.Error} Error returned by the API
101103
*/
102104
async getNextPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
103105
return await this.getPage(response, response.page + 1);
@@ -107,6 +109,7 @@ class {{config.name}} {
107109
* Get previous page of paginated results
108110
* @param response Response to get the previous page of
109111
* @returns The previous page or null if this is the first page
112+
* @throws {Cloudnode.Error} Error returned by the API
110113
*/
111114
async getPreviousPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
112115
return await this.getPage(response, response.page - 1);
@@ -117,6 +120,7 @@ class {{config.name}} {
117120
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
118121
* @param response Response to get all pages of
119122
* @returns All of the data in 1 page
123+
* @throws {Cloudnode.Error} Error returned by the API
120124
*/
121125
async getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>> {
122126
const pages: (true | null)[] = new Array(Math.ceil(response.total / response.limit)).fill(null);

src/Cloudnode.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@ declare class Cloudnode {
1616
* @param response Response to get a different page of
1717
* @param page Page to get
1818
* @returns The new page or null if the page is out of bounds
19+
* @throws {Cloudnode.Error} Error returned by the API
1920
*/
2021
getPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>, page: number): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
2122
/**
2223
* Get next page of paginated results
2324
* @param response Response to get the next page of
2425
* @returns The next page or null if this is the last page
26+
* @throws {Cloudnode.Error} Error returned by the API
2527
*/
2628
getNextPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
2729
/**
2830
* Get previous page of paginated results
2931
* @param response Response to get the previous page of
3032
* @returns The previous page or null if this is the first page
33+
* @throws {Cloudnode.Error} Error returned by the API
3134
*/
3235
getPreviousPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null>;
3336
/**
3437
* Get all other pages of paginated results and return the complete data
3538
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
3639
* @param response Response to get all pages of
3740
* @returns All of the data in 1 page
41+
* @throws {Cloudnode.Error} Error returned by the API
3842
*/
3943
getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>>;
4044
newsletter: {

src/Cloudnode.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class Cloudnode {
8484
* @param response Response to get a different page of
8585
* @param page Page to get
8686
* @returns The new page or null if the page is out of bounds
87+
* @throws {Cloudnode.Error} Error returned by the API
8788
*/
8889
async getPage(response, page) {
8990
if (page * response.limit > response.total || page < 1)
@@ -96,6 +97,7 @@ class Cloudnode {
9697
* Get next page of paginated results
9798
* @param response Response to get the next page of
9899
* @returns The next page or null if this is the last page
100+
* @throws {Cloudnode.Error} Error returned by the API
99101
*/
100102
async getNextPage(response) {
101103
return await this.getPage(response, response.page + 1);
@@ -104,6 +106,7 @@ class Cloudnode {
104106
* Get previous page of paginated results
105107
* @param response Response to get the previous page of
106108
* @returns The previous page or null if this is the first page
109+
* @throws {Cloudnode.Error} Error returned by the API
107110
*/
108111
async getPreviousPage(response) {
109112
return await this.getPage(response, response.page - 1);
@@ -113,6 +116,7 @@ class Cloudnode {
113116
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
114117
* @param response Response to get all pages of
115118
* @returns All of the data in 1 page
119+
* @throws {Cloudnode.Error} Error returned by the API
116120
*/
117121
async getAllPages(response) {
118122
const pages = new Array(Math.ceil(response.total / response.limit)).fill(null);

src/Cloudnode.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Cloudnode {
8686
* @param response Response to get a different page of
8787
* @param page Page to get
8888
* @returns The new page or null if the page is out of bounds
89+
* @throws {Cloudnode.Error} Error returned by the API
8990
*/
9091
async getPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>, page: number): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
9192
if (page * response.limit > response.total || page < 1) return null;
@@ -98,6 +99,7 @@ class Cloudnode {
9899
* Get next page of paginated results
99100
* @param response Response to get the next page of
100101
* @returns The next page or null if this is the last page
102+
* @throws {Cloudnode.Error} Error returned by the API
101103
*/
102104
async getNextPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
103105
return await this.getPage(response, response.page + 1);
@@ -107,6 +109,7 @@ class Cloudnode {
107109
* Get previous page of paginated results
108110
* @param response Response to get the previous page of
109111
* @returns The previous page or null if this is the first page
112+
* @throws {Cloudnode.Error} Error returned by the API
110113
*/
111114
async getPreviousPage<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>> | null> {
112115
return await this.getPage(response, response.page - 1);
@@ -117,6 +120,7 @@ class Cloudnode {
117120
* > **Warning:** Depending on the amount of data, this can take a long time and use a lot of memory.
118121
* @param response Response to get all pages of
119122
* @returns All of the data in 1 page
123+
* @throws {Cloudnode.Error} Error returned by the API
120124
*/
121125
async getAllPages<T>(response: Cloudnode.ApiResponse<Cloudnode.PaginatedData<T>>): Promise<Cloudnode.PaginatedData<T>> {
122126
const pages: (true | null)[] = new Array(Math.ceil(response.total / response.limit)).fill(null);

0 commit comments

Comments
 (0)