Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #6 from kayac/feature/fix-error-report-body-builde…
Browse files Browse the repository at this point in the history
…r-use-kv2json

use kv2json for Error Body build.
  • Loading branch information
mashiike authored Jul 2, 2020
2 parents 518b9c0 + 7d71cab commit f783614
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
.vscode
export

# Download bin/package
bin/kv2json

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SHELL = /usr/bin/env bash -xe

PWD := $(shell pwd)

build:
build: bin/kv2json
@rm -rf export
@mkdir export
@zip -yr export/layer.zip bootstrap bin lib libexec share
Expand All @@ -25,6 +25,10 @@ update-awscli:
lambci/lambda:build-python3.6 \
bash -c /root/bash-lambda-layer/update-awscli.sh

bin/kv2json:
cd bin/ \
&& curl -sOL https://raw.githubusercontent.com/Songmu/App-KV2JSON/master/kv2json \
&& chmod +x kv2json

.PHONY: \
build
Expand Down
6 changes: 3 additions & 3 deletions bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export AWS_CONFIG_FILE="/tmp/.aws/config"
sendInitError () {
ERROR_MESSAGE=$1
ERROR_TYPE=$2
ERROR="{\"errorMessage\": \"$ERROR_MESSAGE\", \"errorType\": \"$ERROR_TYPE\"}"
ERROR=$(kv2json errorMessage="$ERROR_MESSAGE" errorType="$ERROR_TYPE" )
curl -sS -X POST -d "$ERROR" --header "Lambda-Runtime-Function-Error-Type: Unhandled" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/init/error" > /dev/null
}

Expand All @@ -23,7 +23,7 @@ sendRuntimeError () {
ERROR_MESSAGE=$2
ERROR_TYPE=$3
STACK_TRACE=$4
ERROR="{\"errorMessage\": \"$ERROR_MESSAGE\", \"errorType\": \"$ERROR_TYPE\", \"stackTrace\": \"$STACK_TRACE\"}"
ERROR=$(kv2json errorMessage="$ERROR_MESSAGE" errorType="$ERROR_TYPE" stackTrace="$STACK_TRACE")
curl -sS -X POST -d "$ERROR" --header "Lambda-Runtime-Function-Error-Type: Unhandled" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/${REQUEST_ID}/error" > /dev/null

}
Expand Down Expand Up @@ -88,4 +88,4 @@ do
rm -f -- "$RESPONSE"
unset HEADERS
unset RESPONSE
done
done

0 comments on commit f783614

Please sign in to comment.