You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/10/23 02:11:13 UTC
[GitHub] nzomkxia closed pull request #157: frontend error handing #152
nzomkxia closed pull request #157: frontend error handing #152
URL: https://github.com/apache/incubator-dubbo-ops/pull/157
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/README.md b/README.md
index 0d95fa4..1b08e2e 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@
> The generic configuration, it's permanent.
> - `application-develop.properties`
> The configuration for develop, it will be work when you use Maven's `develop` Profile.
-> - `application-production.properties` (default)
+> - `application-production.properties` (default)
> The configuration for production, it will be work when you use Maven's `production` Profile. Meanwhile, it's maven's default profile in this project.
### Build setup
diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/CommonResponse.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/CommonResponse.java
index b1f5f11..20ee8d5 100644
--- a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/CommonResponse.java
+++ b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/CommonResponse.java
@@ -16,9 +16,6 @@
*/
package org.apache.dubbo.admin.common;
-import com.google.common.collect.Lists;
-
-import java.util.Collection;
import java.util.HashMap;
/**
@@ -32,6 +29,10 @@
private static final String DATA = "data";
+ private static final String REDIRECT = "redirect";
+
+ private static final String EMPTY = "";
+
public boolean isSuccess() {
return get(SUCCESS) != null && (Boolean) get(SUCCESS);
}
@@ -40,7 +41,7 @@ public String getMessage() {
if (get(MESSAGE) != null) {
return (String) get(MESSAGE);
}
- return "";
+ return EMPTY;
}
private CommonResponse() {
@@ -66,32 +67,19 @@ public CommonResponse fail(String message) {
}
public CommonResponse redirect(String url) {
- this.put("redirect", url);
+ this.put(REDIRECT, url);
return this;
}
public CommonResponse setData(Object data) {
- Collection collection;
- if (!containsKey(DATA) || get(DATA) == null) {
- collection = Lists.newArrayList();
- put(DATA, collection);
- } else {
- collection = (Collection) get(DATA);
- }
- collection.add(data);
- return this;
+ return putData(DATA, data);
}
- public CommonResponse setData(String key, Object data) {
+ public CommonResponse putData(String key, Object data) {
this.put(key, data);
return this;
}
- public CommonResponse setData(Collection collection) {
- this.put(DATA, collection);
- return this;
- }
-
public static CommonResponse createCommonResponse() {
CommonResponse commonResponse = new CommonResponse();
commonResponse.success();
@@ -104,4 +92,4 @@ public static CommonResponse createCommonResponse(Object data) {
commonResponse.setData(data);
return commonResponse;
}
-}
\ No newline at end of file
+}
diff --git a/dubbo-admin-frontend/src/components/http-common.js b/dubbo-admin-frontend/src/components/http-common.js
index 5c44c9a..6516020 100644
--- a/dubbo-admin-frontend/src/components/http-common.js
+++ b/dubbo-admin-frontend/src/components/http-common.js
@@ -15,7 +15,23 @@
* limitations under the License.
*/
import axios from 'axios'
+import Vue from 'vue'
+import HttpStatus from 'http-status'
-export const AXIOS = axios.create({
+let instance = axios.create({
baseURL: 'http://localhost:8080/api/dev'
})
+
+instance.interceptors.response.use((response) => {
+ return response
+}, (error) => {
+ if (error.message.indexOf('Network Error') >= 0) {
+ Vue.prototype.$notify.error('Network error, please check your network settings!')
+ } else if (error.response.status === HttpStatus.UNAUTHORIZED) {
+ // TODO jump to url
+ } else if (error.response.status >= HttpStatus.BAD_REQUEST) {
+ Vue.prototype.$notify.error(error.response.data.message)
+ }
+})
+
+export const AXIOS = instance
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org