@volant-autonomy/via-sdk 1.3816.1 → 1.3832.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/dist/index.cjs.js CHANGED
@@ -786,7 +786,7 @@ function defaultPathSerializer(pathname, pathParams) {
786
786
  return nextURL;
787
787
  }
788
788
 
789
- var version = "1.3816.1";
789
+ var version = "1.3832.1";
790
790
 
791
791
  const querySerializer = createQuerySerializer();
792
792
  class Fetcher {
@@ -842,10 +842,30 @@ class Fetcher {
842
842
  }
843
843
  /** Transforms an error from the api into an {@link SdkErrorModel} */
844
844
  async parseError(response) {
845
- var _a;
846
- const error = (await response.json());
847
- // NOTE: throws away the status codes inside of the individual errors
848
- if (((_a = error === null || error === void 0 ? void 0 : error.errors) === null || _a === void 0 ? void 0 : _a.length) === 0) {
845
+ const data = await response.text();
846
+ let errorData;
847
+ // NOTE: This function does not handle the case where the API returns valid json
848
+ // that does not fit the schema (as in the `errors` list is missing)
849
+ try {
850
+ errorData = JSON.parse(data);
851
+ }
852
+ catch (err) {
853
+ if (err instanceof SyntaxError) {
854
+ return {
855
+ status: String(response.status),
856
+ errors: [
857
+ {
858
+ status: String(response.status),
859
+ detail: data
860
+ }
861
+ ]
862
+ };
863
+ }
864
+ else {
865
+ throw err;
866
+ }
867
+ }
868
+ if (errorData.errors.length === 0) {
849
869
  return {
850
870
  status: String(response.status),
851
871
  errors: [
@@ -859,7 +879,7 @@ class Fetcher {
859
879
  else {
860
880
  return {
861
881
  status: String(response.status),
862
- errors: error === null || error === void 0 ? void 0 : error.errors.map((err) => {
882
+ errors: errorData.errors.map((err) => {
863
883
  return {
864
884
  status: String(err.status),
865
885
  detail: err.detail