use of com.eros.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class EventFetch method parseError.
private void parseError(Context context, Exception e, JSCallback callback) {
if (e instanceof CancelException) {
// request canceled
ModalManager.BmLoading.dismissLoading(context);
return;
}
AxiosResultBean bean = new AxiosResultBean();
if (e instanceof HttpException) {
HttpException httpException = (HttpException) e;
bean.status = httpException.getmErrorCode();
bean.errorMsg = httpException.getmErrorMessage();
} else if (e instanceof IrregularUrlException) {
IrregularUrlException irregularUrlException = (IrregularUrlException) e;
bean.status = 9;
bean.errorMsg = irregularUrlException.getmErrosMeeage();
} else {
bean.status = 9;
bean.errorMsg = e.getMessage();
}
if (callback != null) {
callback.invoke(bean);
}
}
use of com.eros.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class AxiosManager method delete.
public void delete(String url, String content, HashMap<String, String> header, Callback callBack, Object tag, long timeout) {
url = safeUrl(url);
if (url == null) {
if (callBack != null) {
callBack.onError(null, new IrregularUrlException("url不合法"), 0);
}
return;
}
if (header == null) {
header = new HashMap<>();
}
setTimeout(timeout);
OtherRequestBuilder builder = OkHttpUtils.delete().url(url).tag(tag).headers(header);
if (content != null) {
builder.requestBody(createRequestBodyByMediaType(header, content));
}
builder.build().execute(callBack);
}
use of com.eros.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class AxiosManager method get.
public void get(String mUrl, HashMap<String, String> params, HashMap<String, String> header, Callback callback, Object tag, long timeout) {
mUrl = safeUrl(mUrl);
if (mUrl == null) {
if (callback != null) {
callback.onError(null, new IrregularUrlException("url不合法"), 0);
}
return;
}
if (header == null) {
header = new HashMap<>();
}
setTimeout(timeout);
GetBuilder builder = OkHttpUtils.get().url(mUrl).tag(tag).headers(header);
generateParams(params, builder);
builder.build().execute(callback);
}
use of com.eros.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class AxiosManager method post.
public void post(String mUrl, String data, HashMap<String, String> header, Callback stringCallback, Object tag, long timeout) {
mUrl = safeUrl(mUrl);
if (mUrl == null) {
if (stringCallback != null) {
stringCallback.onError(null, new IrregularUrlException("url不合法"), 0);
}
return;
}
setTimeout(timeout);
String contentType = null;
if (header != null) {
contentType = header.get("Content-Type");
}
if (TextUtils.isEmpty(contentType)) {
contentType = DEFAULT_MEDIATYPE;
}
if (contentType.equals(DEFAULT_MEDIATYPE)) {
OkHttpUtils.postString().url(mUrl).content(data).mediaType(MediaType.parse(contentType)).headers(header).tag(tag).build().execute(stringCallback);
} else {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
HashMap params = parseManager.parseFetchParams(data);
OkHttpUtils.post().url(mUrl).params(params).headers(header).build().execute(stringCallback);
}
}
use of com.eros.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class AxiosManager method patch.
public void patch(String url, String content, HashMap<String, String> header, Callback callback, Object tag, long timeout) {
url = safeUrl(url);
if (url == null) {
if (callback != null) {
callback.onError(null, new IrregularUrlException("url不合法"), 0);
}
return;
}
if (header == null) {
header = new HashMap<>();
}
setTimeout(timeout);
OtherRequestBuilder builder = OkHttpUtils.patch().url(url).tag(tag).headers(header);
if (content != null) {
builder.requestBody(createRequestBodyByMediaType(header, content));
}
builder.build().execute(callback);
}
Aggregations