@@ -5,7 +5,9 @@ import { customDeepEqual } from '../lib/customDeepEqual';
55
66type InstanceType = 'callFrame' | 'callObject' ;
77
8- const defaultOptions : DailyFactoryOptions = { } ;
8+ const defaultOptions : DailyFactoryOptions = {
9+ strictMode : true ,
10+ } ;
911const defaultShouldCreateInstance = ( ) => true ;
1012
1113export interface Props {
@@ -100,23 +102,30 @@ export const useCallInstance = (
100102 * but should be created.
101103 * Important to spread props, because createCallObject/createFrame alters the passed object (adds layout and dailyJsVersion).
102104 */
103- switch ( type ) {
104- case 'callFrame' :
105- co = parentElRef ?. current
106- ? Daily . createFrame ( parentElRef . current , { ...options } )
107- : Daily . createFrame ( { ...options } ) ;
108- break ;
109- case 'callObject' :
110- co = Daily . createCallObject ( { ...options } ) ;
111- break ;
105+ try {
106+ switch ( type ) {
107+ case 'callFrame' :
108+ co = parentElRef ?. current
109+ ? Daily . createFrame ( parentElRef . current , { ...options } )
110+ : Daily . createFrame ( { ...options } ) ;
111+ break ;
112+ case 'callObject' :
113+ co = Daily . createCallObject ( { ...options } ) ;
114+ break ;
115+ }
116+ lastUsedOptions . current = options ;
117+
118+ setCallInstance ( co ) ;
119+
120+ co . once ( 'call-instance-destroyed' , handleDestroyedInstance ) ;
121+ } catch ( e ) {
122+ console . error ( 'Error creating call instance:' , e ) ;
123+ if ( options . strictMode ) {
124+ throw e ;
125+ }
112126 }
113- lastUsedOptions . current = options ;
114127 }
115128
116- setCallInstance ( co ) ;
117-
118- co . once ( 'call-instance-destroyed' , handleDestroyedInstance ) ;
119-
120129 /**
121130 * No cleanup phase here, because callObject.destroy() returns a Promise.
122131 * We can't have asynchronous cleanups in a useEffect.
0 commit comments