• Ionic2中腾讯Bugly异常捕获以及上报


    Ionic2混合开发,入坑系列:Ionic2中腾讯Bugly异常捕获以及上报

    1、Ionic2中处理全局异常,直接继承IonicErrorHandler即可,代码如下

    import { IonicErrorHandler } from 'ionic-angular';
    import { Bugly } from './../plugins/TX-bugly.plugin'
    import { Config } from './../config/config'
    /**
     * Ionic2全局异常捕获
     */
    export class GlobalIonicErrorHandler extends IonicErrorHandler {
    
    
        /**
         * 异常处理
         * @param err 异常信息
         */
        handleError(err: any): void {
            let _message = err._nativeError || err.message || err._nativeError.message || "";
            let _stack = err._nativeError || err.stack || err._nativeError.stack;
            let params: any = { message: _message, stack: _stack, platform: Config.APP_PLATFORM };
            console.log("错误:" + _message);
            console.log("堆栈:" + _stack);
            Bugly.buglySend(JSON.stringify(params));
        }
    }

    2、在AppModule.ts中将自定义的异常扩类添加到providers中

    import { NgModule, ErrorHandler } from '@angular/core';
    import { IonicApp, IonicModule } from 'ionic-angular';
    import { MyApp } from './app.component';
    import './rxjs-extensions';
    import { GlobalIonicErrorHandler } from './global-error-handler-ionic.extend'

    @NgModule({ declarations: [ MyApp ], bootstrap: [IonicApp], entryComponents: [ MyApp ], imports: [ IonicModule.forRoot(MyApp, { tabsHideOnSubPages: true, iconMode: 'ios', modalEnter: 'modal-slide-in', modalLeave: 'modal-slide-out', tabsPlacement: 'bottom', pageTransition: 'ios' }), ComponentBusinessModule ], providers: [ { provide: ErrorHandler, useClass: GlobalIonicErrorHandler }] }) export class AppModule { }
  • 相关阅读:
    tomcat 堆内存设置
    Java日历类(GregorianCalendar和Calendar)的简单例子
    oracle中的greatest 函数和 least函数
    极光推送
    oracle的start with connect by prior如何使用
    Eclipse菜单栏中Tomcat 插件的配置
    svn取消关联
    nagios检测http
    python升级
    fabric
  • 原文地址:https://www.cnblogs.com/xhh-lite/p/6485126.html
Copyright © 2020-2023  润新知