File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 type LocaleChangeEvent ,
1313 type LocaleLoadEvent ,
1414} from '../events/index.js'
15+ import { cReportError } from '../utils/compat.js'
1516import type { IntlController } from './types.js'
1617
1718export type ControllerEvents =
@@ -134,8 +135,7 @@ export function useEventTargetPartial<T>(controllerBox: {
134135 eventType === 'error' ||
135136 ( eventRegister . get ( 'error' ) ?. size ?? 0 ) < 1
136137 ) {
137- // eslint-disable-next-line no-console
138- console . error ( 'Uncaught' , err )
138+ cReportError ( err )
139139 } else {
140140 const wrappedError = new Error (
141141 `An error occurred while calling the event listener for "${ eventType } "` ,
Original file line number Diff line number Diff line change 1+ declare const reportError : ( ( err : any ) => void ) | undefined
2+
3+ declare const console :
4+ | {
5+ error ( ...args : any [ ] ) : void
6+ }
7+ | undefined
8+
9+ export function cReportError ( err : any ) {
10+ if ( typeof reportError === 'function' ) {
11+ reportError ( err )
12+ return
13+ }
14+
15+ if ( typeof console === 'object' && typeof console . error === 'function' ) {
16+ console . error ( 'Uncaught' , err )
17+ return
18+ }
19+
20+ setTimeout ( ( ) => {
21+ throw err
22+ } , 0 )
23+ }
You can’t perform that action at this time.
0 commit comments