druxt-router
Advanced tools
Comparing version 0.24.2 to 0.25.0
# druxt-router | ||
## 0.25.0 | ||
### Minor Changes | ||
- 7b749bd: Added improved error handling. | ||
### Patch Changes | ||
- Updated dependencies [7b749bd] | ||
- druxt@0.16.0 | ||
## 0.24.2 | ||
@@ -4,0 +15,0 @@ |
@@ -107,3 +107,3 @@ import { DruxtClient } from 'druxt'; | ||
const url = `/router/translate-path?path=${path}`; | ||
const response = await this.druxt.axios.get(url, { | ||
const response = await this.druxt.get(url, { | ||
validateStatus: (status) => status < 500 | ||
@@ -151,5 +151,12 @@ }); | ||
if (!(response.status >= 200 && response.status < 300)) { | ||
const error = new Error(); | ||
error.response = response; | ||
throw error; | ||
if (response.status === 404) { | ||
if (typeof response.data !== "object") { | ||
response.data = { errors: [{ | ||
detail: "Please ensure the Decoupled Router module is installed and configured correctly." | ||
}] }; | ||
} else if (response.data.message || response.data.details) { | ||
response.data.errors = [{ detail: [response.data.message, response.data.details].filter((s) => s).join("\n") }]; | ||
} | ||
} | ||
this.druxt.error({ response }, { url }); | ||
} | ||
@@ -156,0 +163,0 @@ return route; |
@@ -115,3 +115,3 @@ 'use strict'; | ||
const url = `/router/translate-path?path=${path}`; | ||
const response = await this.druxt.axios.get(url, { | ||
const response = await this.druxt.get(url, { | ||
validateStatus: (status) => status < 500 | ||
@@ -159,5 +159,12 @@ }); | ||
if (!(response.status >= 200 && response.status < 300)) { | ||
const error = new Error(); | ||
error.response = response; | ||
throw error; | ||
if (response.status === 404) { | ||
if (typeof response.data !== "object") { | ||
response.data = { errors: [{ | ||
detail: "Please ensure the Decoupled Router module is installed and configured correctly." | ||
}] }; | ||
} else if (response.data.message || response.data.details) { | ||
response.data.errors = [{ detail: [response.data.message, response.data.details].filter((s) => s).join("\n") }]; | ||
} | ||
} | ||
this.druxt.error({ response }, { url }); | ||
} | ||
@@ -164,0 +171,0 @@ return route; |
{ | ||
"name": "druxt-router", | ||
"version": "0.24.2", | ||
"version": "0.25.0", | ||
"description": "Drupal router for Nuxt, powered by the Drupal Decoupled Router module.", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"dependencies": { | ||
"druxt": "^0.15.0", | ||
"druxt": "^0.16.0", | ||
"url-parse": "^1.4.7" | ||
@@ -48,0 +48,0 @@ }, |
37014
747
+ Addeddruxt@0.16.0(transitive)
- Removeddruxt@0.15.0(transitive)
Updateddruxt@^0.16.0