Skip to content

Commit 61f8b9a

Browse files
author
郭庆哲
committed
+add Exception when script is not exist :D
1 parent e2e4019 commit 61f8b9a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/Async.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace Mutilprocessing;
44

55
require_once __DIR__ . '/FunctionParser.php';
6+
require_once __DIR__ . '/Exception/FileNotFoundException.php';
67

8+
use Mutilprocessing\Exception\FileNotFoundException;
79
use Mutilprocessing\FunctionParser;
810

911
class Async
@@ -48,6 +50,10 @@ public function start($scriptname, $args = [], $envs = [])
4850
$cwd = __DIR__;
4951
} else {
5052
$cwd = '.';
53+
// judge if file exists
54+
if (!is_file($scriptname)) {
55+
throw new FileNotFoundException($scriptname." is not found");
56+
}
5157
}
5258
if ($args == []) {
5359
$argsStr = '';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: shixi_qingzhe
5+
* Date: 18/8/9
6+
* Time: 下午5:11
7+
*/
8+
9+
namespace Mutilprocessing\Exception;
10+
11+
use Throwable;
12+
13+
class FileNotFoundException extends \Exception
14+
{
15+
}

0 commit comments

Comments
 (0)