This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Json format: refactor error handling + add JSON_UNESCAPED_UNICODE #25
Merged
timothymarois
merged 4 commits into
tmarois:1.0
from
assemblie:refactor-format-error-handling
Sep 3, 2018
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,6 @@ | ||
<?php namespace Filebase\Filesystem; | ||
|
||
class FilesystemException extends \Exception | ||
{ | ||
|
||
} |
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,6 @@ | ||
<?php namespace Filebase\Filesystem; | ||
|
||
class ReadingException extends FilesystemException | ||
{ | ||
|
||
} |
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,6 @@ | ||
<?php namespace Filebase\Filesystem; | ||
|
||
class SavingException extends FilesystemException | ||
{ | ||
|
||
} |
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,6 @@ | ||
<?php namespace Filebase\Format; | ||
|
||
class DecodingException extends FormatException | ||
{ | ||
|
||
} |
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,6 @@ | ||
<?php namespace Filebase\Format; | ||
|
||
class EncodingException extends FormatException | ||
{ | ||
|
||
} |
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,18 @@ | ||
<?php namespace Filebase\Format; | ||
|
||
class FormatException extends \Exception | ||
{ | ||
private $inputData; | ||
|
||
public function __construct($message, $code = 0, \Exception $previous = null, $inputData = null) | ||
{ | ||
parent::__construct($message, $code, $previous); | ||
$this->inputData = $inputData; | ||
} | ||
|
||
public function getInputData() | ||
{ | ||
return $this->inputData; | ||
} | ||
} | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if its ok from users viewpoint that get (read) method returns empty document object if file doesn't exists? seems weird
maybe we should throw en exception in get (read) and implement add/create, getOrCreate or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the initial idea was to provide production sites with safety in case of failure so that you could create new docs without checking if old existed. That's why I built the method
has()
which checks if the document exists.An issue like this came up before where things created when I didn't want them too, so there is a config option for
read_only
so that it only reads the documents that exist. (of course thats not good if you do want to make updates, so its a narrow use-case. But yeah it's not perfect, and could use a bit more transparency for the developer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But as to your point, the
get()
was designed to get a document (from the file system) or an empty document if doenst exist. But only creates a new document in the filesystem if you call thesave()
method. This way you can get all the docs you want and then populate data, so if it exists or not intially, it can be created or updated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@assemblie Do you have a way to chat/talk. Like email, or slack etc? This way we can discuss without having to comment each time? really need a github messaging system...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timothymarois ok i get it imo this approach is ok but we need to state this in documentation explicitly and yes if you have slack workspace invite me here [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@assemblie Agreed. and invite sent.