• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

alkem-io / client-web / #10369

13 Feb 2025 08:25AM UTC coverage: 5.804%. First build
#10369

Pull #7670

travis-ci

Pull Request #7670: testing something

197 of 10756 branches covered (1.83%)

Branch coverage included in aggregate %.

0 of 24 new or added lines in 5 files covered. (0.0%)

1510 of 18656 relevant lines covered (8.09%)

0.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/core/lazyLoading/lazyWithGlobalErrorHandler.ts
1
import React, { type ComponentType } from 'react';
2
import { getGlobalErrorSetter } from './GlobalErrorContext';
3

4
type ImportFunc<T> = () => Promise<{ default: React.ComponentType<T> }>;
5

6
export class LazyLoadError extends Error {
7
  constructor(originalError: Error) {
8
    super(originalError.message);
×
9
    this.name = 'LazyLoadError';
×
10
    Object.setPrototypeOf(this, LazyLoadError.prototype);
×
11
  }
12
}
13

14
export const lazyWithGlobalErrorHandler = <T extends object>(
×
15
  importFunc: ImportFunc<T>,
16
  hoc?: (component: ComponentType<T>) => ComponentType<T>
17
): React.LazyExoticComponent<React.ComponentType<T>> => {
×
18
  return React.lazy(async () => {
×
19
    try {
×
20
      const module = await importFunc();
NEW
21
      const Component = module.default;
×
22
      return { default: hoc ? hoc(Component) : Component };
23
    } catch (error) {
×
24
      const setError = getGlobalErrorSetter();
25
      const originalError: Error =
×
26
        error instanceof Error ? error : error?.['message'] ? new Error(error['message']) : new Error('Unknown error');
27

28
      setError(new LazyLoadError(originalError));
29

30
      // it looks like this error is already logged by the useErrorLoggerLink (network error)
31

×
32
      // Instead of throwing, return a fallback component to prevent
×
33
      // catching it in the ErrorBoundary
34
      return {
35
        default: () => null,
36
      };
37
    }
38
  });
×
39
};
×
40

×
41
export const lazyImportWithErrorHandler = async <T>(importFunc: () => Promise<T>): Promise<T> => {
42
  try {
×
43
    return await importFunc();
44
  } catch (error) {
×
45
    const setError = getGlobalErrorSetter();
46
    const originalError: Error =
×
47
      error instanceof Error ? error : error?.['message'] ? new Error(error['message']) : new Error('Unknown error');
×
48

49
    setError(new LazyLoadError(originalError));
50
    throw new LazyLoadError(originalError);
51
  }
52
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc