File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,4 +147,16 @@ describe("ExtractActionDefinition.run", () => {
147147 expect ( result . success ) . toBe ( false ) ;
148148 expect ( result . message ) . toContain ( "No content extracted" ) ;
149149 } ) ;
150+
151+ it ( "returns formatted root error messages" , async ( ) => {
152+ parseMarkdown . mockRejectedValue ( new Error ( "markdown parse failed" ) ) ;
153+ const ctx = createContext ( ) ;
154+
155+ const result = await ExtractActionDefinition . run ( ctx , {
156+ objective : "Extract content" ,
157+ } ) ;
158+
159+ expect ( result . success ) . toBe ( false ) ;
160+ expect ( result . message ) . toContain ( "markdown parse failed" ) ;
161+ } ) ;
150162} ) ;
Original file line number Diff line number Diff line change @@ -76,6 +76,10 @@ function writeDebugFileSafe(
7676 }
7777}
7878
79+ function formatErrorMessage ( error : unknown ) : string {
80+ return error instanceof Error ? error . message : String ( error ) ;
81+ }
82+
7983export const ExtractActionDefinition : AgentActionDefinition = {
8084 type : "extract" as const ,
8185 actionParams : ExtractAction ,
@@ -101,7 +105,7 @@ export const ExtractActionDefinition: AgentActionDefinition = {
101105 if ( ctx . debug ) {
102106 console . warn (
103107 "[extract] Screenshot capture unavailable, falling back to markdown-only extraction:" ,
104- error
108+ formatErrorMessage ( error )
105109 ) ;
106110 }
107111 }
@@ -172,7 +176,7 @@ export const ExtractActionDefinition: AgentActionDefinition = {
172176 } catch ( error ) {
173177 return {
174178 success : false ,
175- message : `Failed to extract content: ${ error } ` ,
179+ message : `Failed to extract content: ${ formatErrorMessage ( error ) } ` ,
176180 } ;
177181 }
178182 } ,
You can’t perform that action at this time.
0 commit comments