Search in sources :

Example 1 with IrregularUrlException

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);
    }
}
Also used : AxiosResultBean(com.benmu.framework.model.AxiosResultBean) IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException) HttpException(com.benmu.framework.http.okhttp.exception.HttpException) CancelException(com.benmu.framework.http.okhttp.exception.CancelException)

Example 2 with IrregularUrlException

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);
}
Also used : IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Example 3 with IrregularUrlException

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);
}
Also used : OtherRequestBuilder(com.benmu.framework.http.okhttp.builder.OtherRequestBuilder) IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Example 4 with IrregularUrlException

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);
}
Also used : GetBuilder(com.benmu.framework.http.okhttp.builder.GetBuilder) IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Example 5 with IrregularUrlException

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);
}
Also used : OtherRequestBuilder(com.benmu.framework.http.okhttp.builder.OtherRequestBuilder) IrregularUrlException(com.benmu.framework.http.okhttp.exception.IrregularUrlException)

Aggregations

IrregularUrlException (com.benmu.framework.http.okhttp.exception.IrregularUrlException)7 OtherRequestBuilder (com.benmu.framework.http.okhttp.builder.OtherRequestBuilder)3 GetBuilder (com.benmu.framework.http.okhttp.builder.GetBuilder)1 CancelException (com.benmu.framework.http.okhttp.exception.CancelException)1 HttpException (com.benmu.framework.http.okhttp.exception.HttpException)1 AxiosResultBean (com.benmu.framework.model.AxiosResultBean)1