use of com.benmu.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();
}
if (callback != null) {
callback.invoke(bean);
}
}
use of com.benmu.framework.http.okhttp.exception.IrregularUrlException in project WeexErosFramework by bmfe.
the class AxiosManager method head.
public void head(String url, HashMap<String, String> params, HashMap<String, String> header, StringCallback 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<>();
}
if (params == null) {
params = new HashMap<>();
}
setTimeout(timeout);
OkHttpUtils.head().url(url).tag(tag).headers(header).params(params).build().execute(callback);
}
use of com.benmu.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, StringCallback 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);
}
use of com.benmu.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, StringCallback stringCallback, Object tag, long timeout) {
mUrl = safeUrl(mUrl);
if (mUrl == null) {
if (stringCallback != null) {
stringCallback.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(stringCallback);
}
use of com.benmu.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, StringCallback 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);
}
Aggregations