Code Monkey home page Code Monkey logo

Comments (17)

crazecoder avatar crazecoder commented on May 28, 2024

不太清楚你想要什么效果,一般throw就行,如果是错误过滤,有filter参数

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

就是上传指定的字符串,比如网络请求错误,把这条请求的路径参数和返回的状态码上传到bugly

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

试试putUserData方法

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

@crazecoder putUserData已经用过啦,用来标识的,我现在想自定义上传错误,这个putUserData不能再用了哦

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

目前是抓取flutter的异常,利用bugly提供的单独上报方法去做的,单独根据某个异常去上报不太好做,现在能想到的解决方法,就是手动去catch对应异常,然后throw一个带map的自定义Exception,但是总觉得不是太合适,不知道你有没有更好的想法

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024
try{
      throw "123";
    }catch(e){
      throw CustomException(message:e.toString(),map: {"test": "ceshi"});
    }

使用方法类似这样,代码还没上传

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

flutter我也是刚学,您参考一下sentry,国外的,github有flutter版本,看看是怎么做的,这是我接入后的效果
image

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024
try{
      throw "123";
    }catch(e){
      throw CustomException(message:e.toString(),map: {"test": "ceshi"});
    }

使用方法类似这样,代码还没上传

如果这样写,程序进了catch里面,不会崩溃吗?据我了解好像会吧,我现在是只想上传网络请求的报错,不影响程序运行哦

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

异步里是不会影响程序的,还是封装一下吧,类似这种

try {
      throw "123";
    } catch (e) {
      FlutterBugly.throwException(message: e.toString(), data: {"test": "ceshi"});
    }

如果没有其他好的方法,只能这样了

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

flutter我也是刚学,您参考一下sentry,国外的,github有flutter版本,看看是怎么做的,这是我接入后的效果
image

这个是我线上项目的日志,个人觉得还是需要去自定义exception,毕竟框架也不知道返回json的格式
image

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

FlutterBugly

噢噢 目前FlutterBugly.throwException(message: e.toString(), data: {"test": "ceshi"});这样写还没上传对吧

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

能否再简洁一点,还需要写个try catch

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

用FlutterBugly封装一下try throw catch?

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024
static var sentry = SentryClient(dsn: "https://[email protected]/1729182");

sentry.captureException(exception: "接口报错==>${e.response.request.path},状态码:${e.response.statusCode},${e.response.data['Message']}");

类似这样使用

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

try catch 只是为了调试,实际情况,在遇到异常的时候直接throwException就可以了,例如dio里使用

await _dio.get<Map>(url).catchError((_error) {
      if (CancelToken.isCancel(_error)) {
        debugLog('Request canceled! ' + _error.message);
      } else {
        FlutterBugly.throwException(message: _error.toString(), data: {"test": "ceshi"});
      }
      return null;
    });

代码已提交到beta分支,你可以引用beta分支试试

from flutter_bugly.

crazecoder avatar crazecoder commented on May 28, 2024

d3d1ab9
把直接上报方法开放出来了,你或者可以直接用upload

from flutter_bugly.

bianxiang avatar bianxiang commented on May 28, 2024

你可以的,完美!😄

from flutter_bugly.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.