@chaosity/location-client 0.4.0 → 0.4.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.
@@ -1,3 +1,4 @@
1
+ import { parseErrorResponse } from '../transport/errors';
1
2
  /**
2
3
  * Build a map style descriptor URL for the Location Service API.
3
4
  *
@@ -61,7 +62,19 @@ export async function fetchMapStyle(apiUrl, mapStyle, getToken, options = {}) {
61
62
  },
62
63
  });
63
64
  if (!response.ok) {
64
- throw new Error(`Failed to fetch map style: ${response.status} ${response.statusText}`);
65
+ // Read the body. The API sends `{message, code, requestId}` and the message
66
+ // is the whole point of it — for a style request it is Amazon's own
67
+ // sentence, forwarded verbatim by location-service-api#89:
68
+ //
69
+ // 400 "Traffic is not supported for style."
70
+ // 400 "light is not a supported color scheme for style Standard."
71
+ //
72
+ // This used to throw `Failed to fetch map style: 400`, discarding all of it
73
+ // two lines before anyone could read it — the same defect #89 fixed in the
74
+ // API, one layer up. Reuses parseErrorResponse so a style failure arrives as
75
+ // the same LocationServiceException as every other call in this package,
76
+ // with `code`, `statusCode` and `requestId` intact.
77
+ throw parseErrorResponse(response.status, response.statusText, await response.text(), response.headers);
65
78
  }
66
79
  const style = (await response.json());
67
80
  if (language) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaosity/location-client",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Client library for Chaosity Location Service with AWS Location Service compatibility",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",