File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
background-charm-service/src Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { type Charm, CharmManager } from "@commontools/charm";
22import {
33 Cell ,
44 idle ,
5+ isErrorWithContext ,
56 isStream ,
67 onError ,
78 setBobbyServerUrl ,
@@ -144,7 +145,9 @@ async function runCharm(data: { charmId: string }) {
144145 console . log ( `Worker: Successfully executed charm ${ spaceId } /${ charmId } ` ) ;
145146 return { success : true , charmId } ;
146147 } catch ( error ) {
147- const errorMessage = error instanceof Error ? error . message : String ( error ) ;
148+ const errorMessage = isErrorWithContext ( error )
149+ ? `${ error . message } @ ${ error . space } :${ error . charmId } running ${ error . recipeId } `
150+ : String ( error ) ;
148151 console . error (
149152 `Worker error executing charm ${ spaceId } /${ charmId } : ${ errorMessage } ` ,
150153 ) ;
Original file line number Diff line number Diff line change 11export { run , stop } from "./runner.ts" ;
22export { addModuleByRef , raw } from "./module.ts" ;
33export {
4- type Action ,
54 idle ,
5+ isErrorWithContext ,
66 onError ,
77 run as addAction ,
88 unschedule as removeAction ,
@@ -11,7 +11,7 @@ export { getRecipeEnvironment, setRecipeEnvironment } from "./env.ts";
1111export type { DocImpl } from "./doc.ts" ;
1212export type { Cell , CellLink , Stream } from "./cell.ts" ;
1313export type { QueryResult } from "./query-result-proxy.ts" ;
14- export type { ReactivityLog } from "./scheduler.ts" ;
14+ export type { Action , ErrorWithContext , ReactivityLog } from "./scheduler.ts" ;
1515export * as StorageInspector from "./storage/inspector.ts" ;
1616export { getDoc , isDoc } from "./doc.ts" ;
1717export {
@@ -59,8 +59,8 @@ export {
5959 setBlobbyServerUrl ,
6060} from "./blobby-storage.ts" ;
6161export { tsToExports } from "./local-build.ts" ;
62- export {
62+ export {
6363 addCommonIDfromObjectID ,
6464 followAliases ,
65- maybeGetCellLink
65+ maybeGetCellLink ,
6666} from "./utils.ts" ;
Original file line number Diff line number Diff line change @@ -169,6 +169,11 @@ export type ErrorWithContext = Error & {
169169 recipeId : string ;
170170} ;
171171
172+ export function isErrorWithContext ( error : unknown ) : error is ErrorWithContext {
173+ return error instanceof Error && "action" in error && "charmId" in error &&
174+ "space" in error && "recipeId" in error ;
175+ }
176+
172177function handleError ( error : Error , action : any ) {
173178 // TODO(seefeld): This is a rather hacky way to get the context, based on the
174179 // unsafe_binding pattern. Once we replace that mechanism, let's add nicer
You can’t perform that action at this time.
0 commit comments