@ray-js/ray-error-catch
TypeScript icon, indicating that this package has built-in type declarations

0.0.24 • Public • Published

English | 简体中文

@ray-js/ray-error-catch

latest download

Exception Handling Component

    1. When there is an exception in the mini-program, it will be captured and a generic fallback page will be displayed, guiding the user to upload logs to help developers locate the problem.
    1. Provide interfaces for mini-program developers to customize and add logs.
    1. Note ⚠️:
    • Mini-program basic library version requirement:
      • Greater than or equal to 2.13.0.
    • Capture scope:
      • Only exceptions in synchronously executed JavaScript code can be automatically captured.
      • Asynchronous code such as setTimeout and setInterval, AJAX requests, Web Workers, client-side storage, and other asynchronous execution code cannot trigger automatic error catching.

Installation

$ npm install @ray-js/ray-error-catch
# or
$ yarn add @ray-js/ray-error-catch

Usage

import RayErrorCatch from '@ray-js/ray-error-catch';

// Basic usage
const Home = () => {
  return (
    <RayErrorCatch>
      {/* 业务根组件 */}
      <RootELement />
    </RayErrorCatch>
  );
};

// Advanced usage: Allow developers to customize copywriting based on business conditions
const Home = () => {
  return (
    <RayErrorCatch
      errorTitle="自定义异常标题"
      errorText="自定义异常文案"
      submitText="自定义提交文案"
    >
      {/* 业务根组件 */}
      <RootELement />
    </RayErrorCatch>
  );
};
// Advanced usage: allows developers to customize the display of exception pages based on business conditions.
const Home = () => {
  const [forceShow, setForceShow] = useState(false);

  return (
    <RayErrorCatch
      forceShow={forceShow}
      errorTitle="自定义异常标题"
      errorText="自定义异常文案"
      submitText="自定义提交文案"
    >
      {/* 业务根组件 */}
      <RootELement />
    </RayErrorCatch>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i @ray-js/ray-error-catch

Weekly Downloads

148

Version

0.0.24

License

MIT

Unpacked Size

26.2 kB

Total Files

25

Last publish

Collaborators

  • tuyafe