Compare commits
3 Commits
master
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c95b18186 | |||
| 36dee2e18b | |||
| 43a999803b |
58
ReadMe.md
Normal file
58
ReadMe.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Extended Exceptions
|
||||
|
||||
A group of extended Exceptions
|
||||
|
||||
- SQL errors
|
||||
- File handling
|
||||
|
||||
## Setup from central composer
|
||||
|
||||
Setup from gitea internal servers
|
||||
|
||||
```sh
|
||||
composer config repositories.git.egplusww.jp.Composer composer https://git.egplusww.jp/api/packages/Composer/composer
|
||||
```
|
||||
|
||||
Alternative setup composer local zip file repot:
|
||||
`composer config repositories.composer.egplusww.jp composer http://composer.egplusww.jp`
|
||||
|
||||
## Install package
|
||||
|
||||
`composer require egrajp/exceptions-extended`
|
||||
|
||||
## PHP Exception model
|
||||
|
||||
Here's a chart that demonstrates the new hierarchy introduced in PHP 7:
|
||||
|
||||
```txt
|
||||
\Throwable
|
||||
├── \Exception (implements \Throwable)
|
||||
| |── \DOMException (extends \Exception)
|
||||
| ├── \IntlException (extends \Exception)
|
||||
| ├── \JsonException (extends \Exception)
|
||||
| |── \PharException (extends \Exception)
|
||||
| |── \ReflectionException (extends \Exception)
|
||||
| |── \ValueError (extends \Exception)
|
||||
│ ├── \LogicException (extends \Exception)
|
||||
│ │ ├── \BadFunctionCallException (extends \LogicException)
|
||||
│ │ │ └── \BadMethodCallException (extends \BadFunctionCallException)
|
||||
│ │ ├── \DomainException (extends \LogicException)
|
||||
│ │ ├── \InvalidArgumentException (extends \LogicException)
|
||||
│ │ ├── \LengthException (extends \LogicException)
|
||||
│ │ └── \OutOfRangeException (extends \LogicException)
|
||||
│ └── \RuntimeException (extends \Exception)
|
||||
│ ├── \OutOfBoundsException (extends \RuntimeException)
|
||||
│ ├── \OverflowException (extends \RuntimeException)
|
||||
│ ├── \RangeException (extends \RuntimeException)
|
||||
│ ├── \UnderflowException (extends \RuntimeException)
|
||||
│ └── \UnexpectedValueException (extends \RuntimeException)
|
||||
└── \Error (implements \Throwable)
|
||||
├── \AssertionError (extends \Error)
|
||||
├── \ParseError (extends \Error)
|
||||
└── \TypeError (extends \Error)
|
||||
└── \ArgumentCountError (extends \TypeError)
|
||||
└── \ArithmeticError (extends \Error)
|
||||
└── \DivisionByZeroError (extends \ArithmeticError)
|
||||
```
|
||||
|
||||
<http://soba.tokyo.tequila.jp/developers/clemens/php/exceptions-tree.php>
|
||||
@@ -13,9 +13,9 @@
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
"psr-4": {
|
||||
"CoreLibs\\": "src/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
|
||||
2
publish/.gitignore
vendored
Normal file
2
publish/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.zip
|
||||
.env*
|
||||
1
publish/package-download/.gitignore
vendored
Normal file
1
publish/package-download/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.zip
|
||||
97
publish/publish.sh
Executable file
97
publish/publish.sh
Executable file
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
|
||||
PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/";
|
||||
if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then
|
||||
mkdir "${PACKAGE_DOWNLOAD}";
|
||||
fi;
|
||||
VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//");
|
||||
file_last_published="${BASE_FOLDER}last.published";
|
||||
go_flag="$1";
|
||||
|
||||
if [ -z "${VERSION}" ]; then
|
||||
echo "Version must be set in the form x.y.z without any leading characters";
|
||||
exit;
|
||||
fi;
|
||||
# compare version, if different or newer, deploy
|
||||
if [ -f "${file_last_published}" ]; then
|
||||
LAST_PUBLISHED_VERSION=$(cat ${file_last_published});
|
||||
if $(dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"); then
|
||||
echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}";
|
||||
exit;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# read in the .env.deploy file and we must have
|
||||
# for gitea
|
||||
# GITEA_PUBLISH: must be set with a value to trigger publish run
|
||||
# GITEA_UPLOAD_FILENAME
|
||||
# GITEA_USER
|
||||
# GITEA_DEPLOY_TOKEN
|
||||
# GITEA_URL_DL
|
||||
# GITEA_URL_PUSH
|
||||
# for gitlab
|
||||
# GITLAB_PUBLISH: must be set with a value to trigger publish run
|
||||
# GITLAB_USER
|
||||
# GITLAB_TOKEN
|
||||
# GITLAB_URL
|
||||
if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then
|
||||
echo "Deploy enviroment file .env.deploy is missing";
|
||||
exit;
|
||||
fi;
|
||||
set -o allexport;
|
||||
cd ${BASE_FOLDER};
|
||||
source .env.deploy;
|
||||
cd -;
|
||||
set +o allexport;
|
||||
|
||||
if [ "${go_flag}" != "go" ]; then
|
||||
echo "No go flag given";
|
||||
echo "Would publish ${VERSION}";
|
||||
echo "[END]";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
echo "[START]";
|
||||
# gitea
|
||||
# skip iof
|
||||
if [ ! -z "${GITEA_PUBLISH}" ]; then
|
||||
if [ ! -z "${GITEA_UPLOAD_FILENAME}" ] &&
|
||||
[ ! -z "${GITEA_URL_DL}" ] && [ ! -z "${GITEA_URL_PUSH}" ] &&
|
||||
[ ! -z "${GITEA_USER}" ] && [ ! -z "${GITEA_TOKEN}" ]; then
|
||||
if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then
|
||||
curl -LJO \
|
||||
--output-dir "${PACKAGE_DOWNLOAD}" \
|
||||
${GITEA_URL_DL}/v${VERSION}.zip;
|
||||
fi;
|
||||
if [ ! -f "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" ]; then
|
||||
echo "Version file does not exist for ${VERSION}";
|
||||
else
|
||||
curl --user ${GITEA_USER}:${GITEA_TOKEN} \
|
||||
--upload-file "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" \
|
||||
${GITEA_URL_PUSH}?version=${VERSION};
|
||||
echo "${VERSION}" > "${file_last_published}";
|
||||
fi;
|
||||
else
|
||||
echo "Missing either GITEA_UPLOAD_FILENAME, GITEA_URL_DL, GITEA_URL_PUSH, GITEA_USER or GITEA_TOKEN environment variable";
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# gitlab
|
||||
if [ ! -z "${GITLAB_PUBLISH}" ]; then
|
||||
if [ ! -z "${GITLAB_URL}" ] && [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then
|
||||
curl --data tag=v${VERSION} \
|
||||
--header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \
|
||||
"${GITLAB_URL}";
|
||||
curl --data branch=master \
|
||||
--header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \
|
||||
"${GITLAB_URL}";
|
||||
echo "${VERSION}" > "${file_last_published}";
|
||||
else
|
||||
echo "Missing GITLAB_DEPLOY_TOKEN environment variable";
|
||||
fi;
|
||||
fi;
|
||||
echo "";
|
||||
echo "[DONE]";
|
||||
|
||||
# __END__
|
||||
Reference in New Issue
Block a user