本文整理汇总了PHP中Error::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::getMessage方法的具体用法?PHP Error::getMessage怎么用?PHP Error::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getErrorMessage
/**
* @return null|string
*/
public function getErrorMessage()
{
if ($this->error instanceof Error) {
return $this->error->getMessage();
}
return null;
}
示例2: post
protected function post($mode = "", $id = null, $title = "", $description = "", $media = "")
{
//validations
if ($mode != "delete") {
if (!(is_numeric($id) && $id > 0)) {
throw new RestException("99", "ID no es valido");
}
if (empty($title)) {
throw new RestException("99", "Titulo no puede ir vacio");
}
} else {
if (!(is_numeric($id) && $id > 0)) {
throw new RestException("99", "ID no es valido");
}
}
switch ($mode) {
case "edit":
return $this->dp->update($id, $title, $description, $media);
break;
case "delete":
return $this->dp->delete($id);
break;
case "add":
return $this->dp->insert($id, $title, $description, $media);
break;
}
Error::getMessage(304);
}
示例3: testBasic
public function testBasic()
{
$error = new Error('error', 1);
$this->assertSame('error', (string) $error);
$this->assertSame('error', $error->getMessage());
$this->assertSame(1, $error->getCode());
}
示例4: testUnknownLine
public function testUnknownLine()
{
$error = new Error('Some error');
$this->assertSame(-1, $error->getStartLine());
$this->assertSame(-1, $error->getEndLine());
$this->assertSame('Some error on unknown line', $error->getMessage());
}
示例5: __construct
/**
* Wraps the passed Error class
*
* @param Error $error the Error object
*/
public function __construct($error)
{
$this->_error = $error;
$message = $error->getMessage();
$code = $error->getCode();
parent::__construct(sprintf('(%s) - %s', get_class($error), $message), $code);
}
示例6: formatErrorMessage
private function formatErrorMessage(Error $e, $code)
{
if ($e->hasColumnInfo()) {
return $e->getMessageWithColumnInfo($code);
} else {
return $e->getMessage();
}
}
示例7: formatErrorMessage
private function formatErrorMessage(Error $e, $code)
{
if ($e->hasColumnInfo()) {
return $e->getRawMessage() . ' from ' . $e->getStartLine() . ':' . $e->getStartColumn($code) . ' to ' . $e->getEndLine() . ':' . $e->getEndColumn($code);
} else {
return $e->getMessage();
}
}
示例8: fromError
/**
*
* @param \webignition\CssValidatorOutput\Message\Error $error
* @return \webignition\CssValidatorOutput\Message\Warning
*/
public static function fromError(Error $error)
{
$warning = new Warning();
$warning->setContext($error->getContext());
$warning->setLineNumber($error->getLineNumber());
$warning->setMessage($error->getMessage());
$warning->setRef($error->getRef());
return $warning;
}
示例9: handleException
/**
* @param Exception | Error $e
*/
function handleException($e)
{
$request = \OC::$server->getRequest();
// in case the request content type is text/xml - we assume it's a WebDAV request
$isXmlContentType = strpos($request->getHeader('Content-Type'), 'text/xml');
if ($isXmlContentType === 0) {
// fire up a simple server to properly process the exception
$server = new Server();
if (!$e instanceof RemoteException) {
// we shall not log on RemoteException
$server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
}
$server->on('beforeMethod', function () use($e) {
if ($e instanceof RemoteException) {
switch ($e->getCode()) {
case OC_Response::STATUS_SERVICE_UNAVAILABLE:
throw new ServiceUnavailable($e->getMessage());
case OC_Response::STATUS_NOT_FOUND:
throw new \Sabre\DAV\Exception\NotFound($e->getMessage());
}
}
$class = get_class($e);
$msg = $e->getMessage();
throw new ServiceUnavailable("{$class}: {$msg}");
});
$server->exec();
} else {
$statusCode = OC_Response::STATUS_INTERNAL_SERVER_ERROR;
if ($e instanceof \OC\ServiceUnavailableException) {
$statusCode = OC_Response::STATUS_SERVICE_UNAVAILABLE;
}
if ($e instanceof RemoteException) {
// we shall not log on RemoteException
OC_Response::setStatus($e->getCode());
OC_Template::printErrorPage($e->getMessage());
} else {
\OC::$server->getLogger()->logException($e, ['app' => 'remote']);
OC_Response::setStatus($statusCode);
OC_Template::printExceptionErrorPage($e);
}
}
}
示例10: test
public function test()
{
$error = new Error(E_ERROR, 'message', 'file', 0);
$this->assertSame(E_ERROR, $error->getSeverity());
$this->assertSame('message', $error->getMessage());
$this->assertSame('Fatal error', $error->getSeverityAsString());
$this->assertSame('E_ERROR', $error->getSeverityAsConstantName());
$this->assertSame('file', $error->getFile());
$this->assertSame(0, $error->getLine());
$this->assertSame('Fatal error: message in file on line 0', (string) $error);
}
示例11: error
/**
* Set error response
* @param \Sonic\Controller\Error|integer|string $message Error message object, error code or message string
* @param integer $code Error code, only used if message is a string
* @param integer $httpCode HTTP status code
* @return FALSE
*/
protected function error($message = 'invalid request', $code = 0, $httpCode = 0)
{
if (is_numeric($message)) {
$error = new Error($message);
$code = $error->getCode();
$message = $error->getMessage();
} else {
if ($message instanceof Error) {
$code = $message->getCode();
$message = $message->getMessage();
}
}
$this->view->response = array('success' => 0, 'error_code' => $code, 'error_description' => $message);
if ($httpCode) {
$this->httpStatus($httpCode);
}
return FALSE;
}
示例12: logError
/**
* log error to configured log facility
*
* @param Error $error the error
*
* @return bool
*
* @todo finish!
*/
protected function logError($error)
{
return error_log($error->getMessage());
}
示例13: __construct
public function __construct(Error $error)
{
parent::__construct($error->getMessage() ? $error->getMessage() : '');
$this->error = $error;
}
示例14: testValidMessage
public function testValidMessage()
{
$errorMessage = 'This is an error message';
$error = new Error($errorMessage);
$this->assertEquals($errorMessage, $error->getMessage());
}
示例15: testGetMessage
public function testGetMessage()
{
$this->assertEquals('error_message', $this->error->getMessage());
}