@argos-ci/api-client 0.2.1-alpha.5 → 0.4.0

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FetchResponse } from "openapi-fetch";
1
2
  /**
2
3
  * This file was auto-generated by openapi-typescript.
3
4
  * Do not make direct changes to the file.
@@ -546,4 +547,11 @@ declare function createClient(options: {
546
547
  baseUrl?: string;
547
548
  authToken: string;
548
549
  }): import("openapi-fetch").Client<paths, `${string}/${string}`>;
549
- export { ArgosAPIClient, createClient };
550
+ declare class APIError extends Error {
551
+ constructor(message: string);
552
+ }
553
+ /**
554
+ * Handle API errors.
555
+ */
556
+ declare function throwAPIError(fetchResponse: FetchResponse<any, any, any>): never;
557
+ export { ArgosAPIClient, createClient, APIError, throwAPIError };
package/dist/index.mjs CHANGED
@@ -11,5 +11,19 @@ import createFetchClient from 'openapi-fetch';
11
11
  }
12
12
  });
13
13
  }
14
+ class APIError extends Error {
15
+ constructor(message){
16
+ super(message);
17
+ }
18
+ }
19
+ /**
20
+ * Handle API errors.
21
+ */ function throwAPIError(fetchResponse) {
22
+ const { error, response } = fetchResponse;
23
+ if (error && typeof error === "object" && "error" in error && typeof error.error === "string") {
24
+ throw new APIError(error.error);
25
+ }
26
+ throw new APIError(`API error: ${response.status} ${response.statusText}`);
27
+ }
14
28
 
15
- export { createClient };
29
+ export { APIError, createClient, throwAPIError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/api-client",
3
3
  "description": "Argos API client.",
4
- "version": "0.2.1-alpha.5+fe38977",
4
+ "version": "0.4.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -48,5 +48,5 @@
48
48
  "dependencies": {
49
49
  "openapi-fetch": "^0.11.1"
50
50
  },
51
- "gitHead": "fe389774403ee2b9857c38c02531ed0e79d6a4fd"
51
+ "gitHead": "d5b9650164fd482ee2b4dbf5c93fcef591f447eb"
52
52
  }