@@ -366,7 +366,11 @@ export async function getOneLogWithReconstruction(
366366 . limit ( 1 ) ;
367367
368368 if ( result . length === 0 ) {
369- throw new Error ( 'Activity log not found' ) ;
369+ throw new ORPCError ( 'NOT_FOUND' , {
370+ status : 404 ,
371+ message : 'Activity log not found' ,
372+ data : { id } ,
373+ } ) ;
370374 }
371375
372376 const log = result [ 0 ] ;
@@ -444,26 +448,29 @@ export async function exportResponseByIdAndFormat(
444448 if ( readResponse . markdown ) {
445449 return readResponse . markdown ;
446450 }
451+ const message =
452+ 'No markdown content available for this request. The original request did not include markdown extraction.' ;
447453 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
448454 status : 400 ,
449- message :
450- 'No markdown content available for this request. The original request did not include markdown extraction.' ,
451- data : { id, path : activity . path } ,
455+ message,
456+ data : { id, path : activity . path , message } ,
452457 } ) ;
453458 }
454459 // Error response
460+ const message = 'Cannot export markdown from error response' ;
455461 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
456462 status : 400 ,
457- message : 'Cannot export markdown from error response' ,
458- data : { id, path : activity . path } ,
463+ message,
464+ data : { id, path : activity . path , message } ,
459465 } ) ;
460466 }
461467
462468 // Links endpoints don't have markdown
469+ const message = `Markdown export is not supported for ${ activity . path } endpoint` ;
463470 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
464471 status : 400 ,
465- message : `Markdown export is not supported for ${ activity . path } endpoint` ,
466- data : { id, path : activity . path } ,
472+ message,
473+ data : { id, path : activity . path , message } ,
467474 } ) ;
468475 }
469476
@@ -479,34 +486,39 @@ export async function exportResponseByIdAndFormat(
479486 if ( 'tree' in linksResponse && linksResponse . tree ) {
480487 return linksResponse . tree ;
481488 }
489+ const message =
490+ 'No links tree available for this request. The original request did not include tree generation.' ;
482491 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
483492 status : 400 ,
484- message :
485- 'No links tree available for this request. The original request did not include tree generation.' ,
486- data : { id, path : activity . path } ,
493+ message,
494+ data : { id, path : activity . path , message } ,
487495 } ) ;
488496 }
489497 // Error response
498+ const message = 'Cannot export links from error response' ;
490499 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
491500 status : 400 ,
492- message : 'Cannot export links from error response' ,
493- data : { id, path : activity . path } ,
501+ message,
502+ data : { id, path : activity . path , message } ,
494503 } ) ;
495504 }
496505
497506 // Read endpoints don't have links tree
507+ const message = `Links export is not supported for ${ activity . path } endpoint` ;
498508 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
499509 status : 400 ,
500- message : `Links export is not supported for ${ activity . path } endpoint` ,
501- data : { id, path : activity . path } ,
510+ message,
511+ data : { id, path : activity . path , message } ,
502512 } ) ;
503513 }
504514
505- default :
515+ default : {
516+ const message = `Unsupported export format: ${ format } ` ;
506517 throw new ORPCError ( 'INVALID_EXPORT_FORMAT' , {
507518 status : 400 ,
508- message : `Unsupported export format: ${ format } ` ,
509- data : { id, format } ,
519+ message,
520+ data : { id, format, message } ,
510521 } ) ;
522+ }
511523 }
512524}
0 commit comments