Skip to content

Commit

Permalink
Merge pull request #1288 from polywrap/throw-in-get-implementations
Browse files Browse the repository at this point in the history
Fix: correctly handle error in getImplementations algorithm
  • Loading branch information
cbrzn authored Oct 5, 2022
2 parents 6436804 + df20049 commit 30f7f64
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/js/core/src/algorithms/get-implementations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getImplementations = Tracer.traceFunc(
const addAllImplementationsFromImplementationsArray = (
implementationsArray: readonly InterfaceImplementations<Uri>[],
wrapperInterfaceUri: Uri
) => {
): Result<undefined, Error> => {
for (const interfaceImplementations of implementationsArray) {
let fullyResolvedUri: Uri;
if (redirects) {
Expand All @@ -32,7 +32,7 @@ export const getImplementations = Tracer.traceFunc(
redirects
);
if (!redirectsResult.ok) {
continue;
return redirectsResult;
}
fullyResolvedUri = redirectsResult.value;
} else {
Expand All @@ -45,6 +45,7 @@ export const getImplementations = Tracer.traceFunc(
}
}
}
return ResultOk(undefined);
};

let finalUri = wrapperInterfaceUri;
Expand All @@ -57,8 +58,11 @@ export const getImplementations = Tracer.traceFunc(
finalUri = redirectsResult.value;
}

addAllImplementationsFromImplementationsArray(interfaces, finalUri);
const addAllImp = addAllImplementationsFromImplementationsArray(
interfaces,
finalUri
);

return ResultOk(result);
return addAllImp.ok ? ResultOk(result) : addAllImp;
}
);

0 comments on commit 30f7f64

Please sign in to comment.