@agilecustoms/envctl 1.20.3 → 1.21.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.
@@ -64,24 +64,22 @@ export class HttpClient {
64
64
  throw new Error('Error (network?) making the request:', { cause: error });
65
65
  }
66
66
  const contentType = response.headers?.get('Content-Type') || '';
67
+ const body = contentType.includes('application/json') ? await response.json() : await response.text();
67
68
  if (response.ok) {
68
- if (contentType.includes('application/json')) {
69
- return await response.json();
70
- }
71
- else {
72
- return await response.text();
73
- }
69
+ return body;
74
70
  }
75
- const message = await response.text();
76
71
  if (response.status === 404) {
77
- throw new NotFoundException(message);
72
+ throw new NotFoundException(body);
78
73
  }
79
74
  if (response.status === 422) {
80
- throw new BusinessException(message);
75
+ throw new BusinessException(body);
76
+ }
77
+ if (response.status === 426) {
78
+ throw new KnownException(body.message);
81
79
  }
82
80
  if (response.status >= 500) {
83
81
  logger.info('API Gateway request ID: ' + response.headers.get('x-amzn-requestid'));
84
82
  }
85
- throw new HttpException(`status: ${response.status}, ` + message);
83
+ throw new HttpException(`status: ${response.status}, ` + JSON.stringify(body));
86
84
  }
87
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agilecustoms/envctl",
3
- "version": "1.20.3",
3
+ "version": "1.21.0",
4
4
  "description": "node.js CLI client for manage environments",
5
5
  "keywords": [
6
6
  "terraform wrapper",