-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from Nyholm/error
Adding an Error object
- Loading branch information
Showing
14 changed files
with
147 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\RST; | ||
|
||
use Throwable; | ||
|
||
use function sprintf; | ||
|
||
final class Error | ||
{ | ||
/** @var string */ | ||
private $message; | ||
|
||
/** @var string|null */ | ||
private $file; | ||
|
||
/** @var int|null */ | ||
private $line; | ||
|
||
/** @var Throwable|null */ | ||
private $throwable; | ||
|
||
public function __construct(string $message, ?string $file = null, ?int $line = null, ?Throwable $throwable = null) | ||
{ | ||
$this->message = $message; | ||
$this->file = $file; | ||
$this->line = $line; | ||
$this->throwable = $throwable; | ||
} | ||
|
||
public function asString(): string | ||
{ | ||
$output = $this->message; | ||
if ($this->getFile() !== null) { | ||
$output .= sprintf(' in file "%s"', $this->file); | ||
|
||
if ($this->line !== null) { | ||
$output .= sprintf(' at line %d', $this->line); | ||
} | ||
} | ||
|
||
return $output; | ||
} | ||
|
||
public function getMessage(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
public function getFile(): ?string | ||
{ | ||
if ($this->file === '') { | ||
return null; | ||
} | ||
|
||
return $this->file; | ||
} | ||
|
||
public function getLine(): ?int | ||
{ | ||
return $this->line; | ||
} | ||
|
||
public function getThrowable(): ?Throwable | ||
{ | ||
return $this->throwable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Exception: Exception | ||
Unknown directive: "latex-main" for line ".. latex-main::" | ||
Unknown directive "latex-main" for line ".. latex-main::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
tests/Functional/tests/simple-table-error1/simple-table-error1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
Exception: Exception | ||
Malformed table: content "l" appears in the "gap" on row "Second row Other colllOther col" | ||
in file (unknown) | ||
|
||
=========== ========== ========= | ||
First col Second col Third col | ||
Second row Other colllOther col | ||
Third row Other col Last col | ||
=========== ========== ========= | ||
=========== ========== ========= in file "(unknown)" |
2 changes: 1 addition & 1 deletion
2
tests/Functional/tests/unknown-directive/unknown-directive.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Exception: Exception | ||
Unknown directive: "unknown-directive" for line ".. unknown-directive::" | ||
Unknown directive "unknown-directive" for line ".. unknown-directive::" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters