Skip to content

Commit db3cc93

Browse files
committed
try catch around things that could be null
1 parent 91284aa commit db3cc93

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/FunctionLoader.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,21 @@ export class FunctionLoader implements IFunctionLoader {
3030
}
3131

3232
getInfo(functionId: string): FunctionInfo {
33-
return this._loadedFunctions[functionId].info;
33+
let loadedFunction = this._loadedFunctions[functionId];
34+
if (loadedFunction && loadedFunction.info) {
35+
return loadedFunction.info;
36+
} else {
37+
throw `Function info for '${functionId}' is not loaded and cannot be invoked.`;
38+
}
3439
}
3540

3641
getFunc(functionId: string): Function {
37-
return this._loadedFunctions[functionId].func;
42+
let loadedFunction = this._loadedFunctions[functionId];
43+
if (loadedFunction && loadedFunction.func) {
44+
return loadedFunction.func;
45+
} else {
46+
throw `Function code for '${functionId}' is not loaded and cannot be invoked.`;
47+
}
3848
}
3949
}
4050

src/Worker.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ export function startNodeWorker(args) {
2424

2525
let connection = `${host}:${port}`;
2626
systemLog(`Worker ${workerId} connecting on ${connection}`);
27-
let eventStream = CreateGrpcEventStream(connection, parseInt(grpcMaxMessageLength));
27+
28+
let eventStream;
29+
try {
30+
eventStream = CreateGrpcEventStream(connection, parseInt(grpcMaxMessageLength));
31+
} catch (exception) {
32+
exception.message = "Error creating GRPC event stream: " + exception.message;
33+
throw exception;
34+
}
2835

2936
let workerChannel = new WorkerChannel(workerId, eventStream, new FunctionLoader());
3037

0 commit comments

Comments
 (0)