@@ -29,6 +29,7 @@ use hyper::body::Bytes;
2929use hyper:: server:: conn:: http1;
3030use hyper:: { Method , StatusCode , Uri } ;
3131use hyper_util:: rt:: TokioIo ;
32+ use log_activities:: obelisk:: log:: log:: Host ;
3233use route_recognizer:: { Match , Router } ;
3334use std:: ops:: Deref ;
3435use std:: str:: FromStr ;
@@ -655,10 +656,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
655656 let execution_id = match concepts:: ExecutionId :: from_str ( & execution_id. id ) {
656657 Ok ( id) => id,
657658 Err ( err) => {
658- return Err ( ScheduleJsonError :: FfqnParsingError ( format ! (
659- "invalid execution ID: {err}"
660- ) )
661- . into ( ) ) ;
659+ let msg = format ! ( "schedule-json: invalid execution ID: {err}" ) ;
660+ self . error ( msg. clone ( ) ) ;
661+ return Err ( ScheduleJsonError :: FfqnParsingError ( msg) . into ( ) ) ;
662662 }
663663 } ;
664664
@@ -667,30 +667,31 @@ impl WebhookSupportHost for WebhookEndpointCtx {
667667 match FunctionFqn :: try_from_tuple ( & function. interface_name , & function. function_name ) {
668668 Ok ( ffqn) => ffqn,
669669 Err ( err) => {
670- return Err ( ScheduleJsonError :: FfqnParsingError ( err. to_string ( ) ) . into ( ) ) ;
670+ let msg = format ! ( "schedule-json: invalid function name: {err}" ) ;
671+ self . error ( msg. clone ( ) ) ;
672+ return Err ( ScheduleJsonError :: FfqnParsingError ( msg) . into ( ) ) ;
671673 }
672674 } ;
673675
674676 // Look up function in registry
675677 let Some ( ( fn_metadata, component_id) ) = self . fn_registry . get_by_exported_function ( & ffqn)
676678 else {
679+ self . error ( "schedule-json: function not found" . to_string ( ) ) ;
677680 return Err ( ScheduleJsonError :: FunctionNotFound . into ( ) ) ;
678681 } ;
679682
680683 // Parse params JSON array
681684 let params_json: Vec < serde_json:: Value > = match serde_json:: from_str ( & params) {
682685 Ok ( serde_json:: Value :: Array ( arr) ) => arr,
683686 Ok ( _) => {
684- return Err ( ScheduleJsonError :: TypeCheckError (
685- "params must be a JSON array" . to_string ( ) ,
686- )
687- . into ( ) ) ;
687+ let msg = "schedule-json: params must be a JSON array" . to_string ( ) ;
688+ self . error ( msg. clone ( ) ) ;
689+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
688690 }
689691 Err ( err) => {
690- return Err ( ScheduleJsonError :: TypeCheckError ( format ! (
691- "cannot parse params as JSON: {err}"
692- ) )
693- . into ( ) ) ;
692+ let msg = format ! ( "schedule-json: cannot parse params as JSON: {err}" ) ;
693+ self . error ( msg. clone ( ) ) ;
694+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
694695 }
695696 } ;
696697
@@ -704,10 +705,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
704705 ) {
705706 Ok ( params) => params,
706707 Err ( err) => {
707- return Err ( ScheduleJsonError :: TypeCheckError ( format ! (
708- "params type checking failed: {err}"
709- ) )
710- . into ( ) ) ;
708+ let msg = format ! ( "schedule-json: params type checking failed: {err}" ) ;
709+ self . error ( msg. clone ( ) ) ;
710+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
711711 }
712712 } ;
713713
@@ -717,10 +717,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
717717 let schedule_at = match history_event_schedule_at. as_date_time ( created_at) {
718718 Ok ( dt) => dt,
719719 Err ( err) => {
720- return Err ( ScheduleJsonError :: TypeCheckError ( format ! (
721- "invalid schedule-at: {err:?}"
722- ) )
723- . into ( ) ) ;
720+ let msg = format ! ( "schedule-json: invalid schedule-at: {err}" ) ;
721+ self . error ( msg. clone ( ) ) ;
722+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
724723 }
725724 } ;
726725
@@ -807,30 +806,31 @@ impl WebhookSupportHost for WebhookEndpointCtx {
807806 match FunctionFqn :: try_from_tuple ( & function. interface_name , & function. function_name ) {
808807 Ok ( ffqn) => ffqn,
809808 Err ( err) => {
810- return Err ( ScheduleJsonError :: FfqnParsingError ( err. to_string ( ) ) . into ( ) ) ;
809+ let msg = format ! ( "call-json: invalid function name: {err}" ) ;
810+ self . error ( msg. clone ( ) ) ;
811+ return Err ( ScheduleJsonError :: FfqnParsingError ( msg) . into ( ) ) ;
811812 }
812813 } ;
813814
814815 // Look up function in registry
815816 let Some ( ( fn_metadata, component_id) ) = self . fn_registry . get_by_exported_function ( & ffqn)
816817 else {
818+ self . error ( "call-json: function not found" . to_string ( ) ) ;
817819 return Err ( ScheduleJsonError :: FunctionNotFound . into ( ) ) ;
818820 } ;
819821
820822 // Parse params JSON array
821823 let params_json: Vec < serde_json:: Value > = match serde_json:: from_str ( & params) {
822824 Ok ( serde_json:: Value :: Array ( arr) ) => arr,
823825 Ok ( _) => {
824- return Err ( ScheduleJsonError :: TypeCheckError (
825- "params must be a JSON array" . to_string ( ) ,
826- )
827- . into ( ) ) ;
826+ let msg = "call-json: params must be a JSON array" . to_string ( ) ;
827+ self . error ( msg. clone ( ) ) ;
828+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
828829 }
829830 Err ( err) => {
830- return Err ( ScheduleJsonError :: TypeCheckError ( format ! (
831- "cannot parse params as JSON: {err}"
832- ) )
833- . into ( ) ) ;
831+ let msg = format ! ( "call-json: cannot parse params as JSON: {err}" ) ;
832+ self . error ( msg. clone ( ) ) ;
833+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
834834 }
835835 } ;
836836
@@ -844,10 +844,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
844844 ) {
845845 Ok ( params) => params,
846846 Err ( err) => {
847- return Err ( ScheduleJsonError :: TypeCheckError ( format ! (
848- "params type checking failed: {err}"
849- ) )
850- . into ( ) ) ;
847+ let msg = format ! ( "call-json: params type checking failed: {err}" ) ;
848+ self . error ( msg. clone ( ) ) ;
849+ return Err ( ScheduleJsonError :: TypeCheckError ( msg) . into ( ) ) ;
851850 }
852851 } ;
853852
@@ -989,7 +988,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
989988 let execution_id = match concepts:: ExecutionId :: from_str ( & execution_id. id ) {
990989 Ok ( id) => id,
991990 Err ( err) => {
992- return Err ( GetStatusError :: ExecutionIdParsingError ( err. to_string ( ) ) . into ( ) ) ;
991+ let msg = format ! ( "get-status: cannot parse execution ID: {err}" ) ;
992+ self . error ( msg. clone ( ) ) ;
993+ return Err ( GetStatusError :: ExecutionIdParsingError ( msg) . into ( ) ) ;
993994 }
994995 } ;
995996
@@ -1054,7 +1055,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
10541055 match concepts:: ExecutionId :: from_str ( & execution_id. id ) {
10551056 Ok ( id) => id,
10561057 Err ( err) => {
1057- return Err ( GetError :: ExecutionIdParsingError ( err. to_string ( ) ) . into ( ) ) ;
1058+ let msg = format ! ( "get: cannot parse execution ID: {err}" ) ;
1059+ self . error ( msg. clone ( ) ) ;
1060+ return Err ( GetError :: ExecutionIdParsingError ( msg) . into ( ) ) ;
10581061 }
10591062 } ;
10601063
@@ -1103,7 +1106,9 @@ impl WebhookSupportHost for WebhookEndpointCtx {
11031106 match concepts:: ExecutionId :: from_str ( & execution_id. id ) {
11041107 Ok ( id) => id,
11051108 Err ( err) => {
1106- return Err ( TryGetError :: ExecutionIdParsingError ( err. to_string ( ) ) . into ( ) ) ;
1109+ let msg = format ! ( "try-get: cannot parse execution ID: {err}" ) ;
1110+ self . error ( msg. clone ( ) ) ;
1111+ return Err ( TryGetError :: ExecutionIdParsingError ( msg) . into ( ) ) ;
11071112 }
11081113 } ;
11091114
@@ -1122,6 +1127,7 @@ impl WebhookSupportHost for WebhookEndpointCtx {
11221127 {
11231128 Ok ( state) => state,
11241129 Err ( DbErrorRead :: NotFound ) => {
1130+ self . error ( format ! ( "try-get: execution not found: {}" , execution_id. id) ) ;
11251131 return Err ( TryGetError :: NotFound . into ( ) ) ;
11261132 }
11271133 Err ( err) => {
0 commit comments