File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -34,11 +34,26 @@ sendResponse () {
3434
3535# Make sure handler file exists
3636if [[ ! -f $LAMBDA_TASK_ROOT /" $( echo $_HANDLER | cut -d. -f1) .sh" ]]; then
37- sendInitError " Failed to load handler '$( echo $_HANDLER | cut -d. -f2) ' from module '$( echo $_HANDLER | cut -d. -f1) '" " InvalidHandlerException"
37+ sendInitError " Failed to load handler '$( echo $_HANDLER | cut -d. -f2) ' from module '$( echo $_HANDLER | cut -d. -f1) '. File '$( echo $_HANDLER | cut -d. -f1) .sh' does not exist." " InvalidHandlerException"
38+ exit 1
3839fi
3940
4041# Initialization
41- source $LAMBDA_TASK_ROOT /" $( echo $_HANDLER | cut -d. -f1) .sh"
42+ SOURCE_RESPONSE=" $( mktemp) "
43+ source $LAMBDA_TASK_ROOT /" $( echo $_HANDLER | cut -d. -f1) .sh" > $SOURCE_RESPONSE 2>&1
44+ if [[ $? -eq " 0" ]]; then
45+ rm -f -- " $SOURCE_RESPONSE "
46+ else
47+ sendInitError " Failed to source file '$( echo $_HANDLER | cut -d. -f1) .sh'. $( cat $SOURCE_RESPONSE ) " " InvalidHandlerException"
48+ exit 1
49+ fi
50+
51+ # Make sure handler function exists
52+ type " $( echo $_HANDLER | cut -d. -f2) " > /dev/null 2>&1
53+ if [[ ! $? -eq " 0" ]]; then
54+ sendInitError " Failed to load handler '$( echo $_HANDLER | cut -d. -f2) ' from module '$( echo $_HANDLER | cut -d. -f1) '. Function '$( echo $_HANDLER | cut -d. -f2) ' does not exist." " InvalidHandlerException"
55+ exit 1
56+ fi
4257
4358# Processing
4459while true
You can’t perform that action at this time.
0 commit comments