2.0.0-beta • Published 4 years ago

universal-error-event v2.0.0-beta

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
4 years ago

group: title: application

title: errorEvent

errorEvent

npm

Monitoring and cancellation of error events

Support

Install

$ npm install universal-error-event --save

Function

onError(callback): void

Listens on the Mini Program error event. This event is triggered as a result of script error or failed API call.

Parameters

function callback The callback function for the Mini Program error event

Parameters

string error Error message, including stacks.

offError(callback): void

Un-listens on Mini Program error event.

Parameters

function callback The callback function for the Mini Program error event

onUnhandledRejection(callback): void

Listen for unhandled Promise rejection events.

Parameters

function callback The callback function for the Mini Program error event

Parameters

Object res |Property |Type |Description| |:--|:--|:--| |reason |string or Error| Reason for rejection, usually an Error object| |promise| Promise.|Rejected Promise object|

offUnhandledRejection(callback): void

Cancel listening for unhandled Promise rejection events.

Parameters

function callback The callback function for the Mini Program error event

Example

import errorEvent from 'universal-error-event';

errorEvent.onError(e => {
  console.log(e);
});

errorEvent.offError();

You can also import from the big package:

import {errorEvent} from 'universal-api';

errorEvent.onError(e => {
  console.log(e);
});

errorEvent.offError();
/**
 * iframe: true
 */
import React from 'react';
export default () => (
  <iframe style={{
      boxShadow: '0 2px 15px rgba(0,0,0,0.1)',
      width: '375px',
      height: '700px'
    }} src='https://herbox.online/p/109000004/app_1aKtEd7SK?previewZoom=100&view=preview&defaultPage=pages/universal-error-event/index&topSlider=false'></iframe>
);
2.0.0-beta

4 years ago