universal-error-event v2.0.0-beta
group: title: application
title: errorEvent
errorEvent
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>
);
4 years ago