@@ -25,6 +25,7 @@ import {
2525 resolveExpiresAtMsFromDurationMs ,
2626} from "@openclaw/normalization-core/number-coercion" ;
2727import type { OpenClawConfig } from "../../config/types.openclaw.js" ;
28+ import { toErrorObject } from "../../infra/errors.js" ;
2829import { resolveOpenClawPackageRootSync } from "../../infra/openclaw-root.js" ;
2930import { privateFileStoreSync } from "../../infra/private-file-store.js" ;
3031import { createSubsystemLogger } from "../../logging/subsystem.js" ;
@@ -1235,7 +1236,7 @@ function postNativeHookRelayBridgeRecord(params: {
12351236 const rejectOnce = ( error : unknown ) => {
12361237 if ( ! settled ) {
12371238 settled = true ;
1238- reject ( toLintErrorObject ( error , "Non-Error rejection" ) ) ;
1239+ reject ( toErrorObject ( error , "Non-Error rejection" ) ) ;
12391240 }
12401241 } ;
12411242 const req = httpRequest (
@@ -2060,10 +2061,10 @@ async function waitForNativeHookRelayApprovalDecision(params: {
20602061 let onAbort : ( ( ) => void ) | undefined ;
20612062 const abortPromise = new Promise < never > ( ( _ , reject ) => {
20622063 if ( params . signal ! . aborted ) {
2063- reject ( toLintErrorObject ( params . signal ! . reason , "Non-Error rejection" ) ) ;
2064+ reject ( toErrorObject ( params . signal ! . reason , "Non-Error rejection" ) ) ;
20642065 return ;
20652066 }
2066- onAbort = ( ) => reject ( toLintErrorObject ( params . signal ! . reason , "Non-Error rejection" ) ) ;
2067+ onAbort = ( ) => reject ( toErrorObject ( params . signal ! . reason , "Non-Error rejection" ) ) ;
20672068 params . signal ! . addEventListener ( "abort" , onAbort , { once : true } ) ;
20682069 } ) ;
20692070 try {
@@ -2380,17 +2381,3 @@ export const testing = {
23802381 } ,
23812382} as const ;
23822383export { testing as __testing } ;
2383-
2384- function toLintErrorObject ( value : unknown , fallbackMessage : string ) : Error {
2385- if ( value instanceof Error ) {
2386- return value ;
2387- }
2388- if ( typeof value === "string" ) {
2389- return new Error ( value ) ;
2390- }
2391- const error = new Error ( fallbackMessage , { cause : value } ) ;
2392- if ( ( typeof value === "object" && value !== null ) || typeof value === "function" ) {
2393- Object . assign ( error , value ) ;
2394- }
2395- return error ;
2396- }
0 commit comments