Skip to content

Commit 0aabe69

Browse files
authored
Merge pull request #94 from ericcrosson-bitgo/use-throw
refactor(express-wrapper): avoid using codec type-guard
2 parents 02832ca + 360202a commit 0aabe69

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/express-wrapper/src/response.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ export const defaultResponseEncoder: ResponseEncoder = (
3838
return;
3939
}
4040
const responseCodec = route.response[status];
41-
if (responseCodec === undefined || !responseCodec.is(payload)) {
41+
try {
42+
expressRes.status(status).json(responseCodec!.encode(payload)).end();
43+
} catch {
4244
console.warn(
4345
"Unable to encode route's return value, did you return the expected type?",
4446
);
4547
expressRes.status(500).end();
46-
return;
4748
}
48-
49-
expressRes.status(status).json(responseCodec.encode(payload)).end();
5049
};

0 commit comments

Comments
 (0)