File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type {
44 ContextSchema ,
55 ContextSchemaList ,
66 EventMap ,
7+ Rejection ,
78 RejectionHandler ,
89 ActionList ,
910 ActionSchema ,
@@ -103,7 +104,7 @@ export const defineActions = <ID extends string, S extends ActionSchema>(
103104 return ( ) => {
104105 const invoker = useInvoker ( )
105106 const endpoint = invoker . endpoint as Endpoint < {
106- invoke ( name : string , ...args : unknown [ ] ) : Promise < unknown >
107+ invoke ( name : string , ...args : unknown [ ] ) : Promise < { payload : unknown , rejection : Rejection | null } >
107108 } >
108109
109110 return ( new Proxy ( { } , {
@@ -120,11 +121,15 @@ export const defineActions = <ID extends string, S extends ActionSchema>(
120121 }
121122
122123 const result = await endpoint . call . invoke ( String ( name ) , ...args )
123- if ( ! expects ( result ) ) {
124+ if ( result . rejection ) {
125+ throw new Error ( `[crm:embed:remote] Invokable ${ String ( name ) } in schema ${ id } failed with: ${ result . rejection . message } ` )
126+ }
127+
128+ if ( ! expects ( result . payload ) ) {
124129 throw new Error ( `[crm:embed:remote] Invalid result for invokable ${ String ( name ) } in schema ${ id } ` )
125130 }
126131
127- return result
132+ return result . payload
128133 }
129134 } ,
130135 } ) as ActionList < S > )
You can’t perform that action at this time.
0 commit comments