Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create error classes for Filesystem errors
- Loading branch information
1 parent
a7293dc
commit 3793a07
Showing
4 changed files
with
71 additions
and
26 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,55 @@ | ||
class Nanoc::DataSources::Filesystem < Nanoc::DataSource | ||
# @api private | ||
module Errors | ||
class Generic < ::Nanoc::Error | ||
end | ||
|
||
class BinaryLayout < Generic | ||
def initialize(content_filename) | ||
super("The layout file '#{content_filename}' is a binary file, but layouts can only be textual") | ||
end | ||
end | ||
|
||
class MultipleMetaFiles < Generic | ||
def initialize(meta_filenames, basename) | ||
super("Found #{meta_filenames.size} meta files for #{basename}; expected 0 or 1") | ||
end | ||
end | ||
|
||
class MultipleContentFiles < Generic | ||
def initialize(content_filenames, basename) | ||
super("Found #{content_filenames.size} content files for #{basename}; expected 0 or 1") | ||
end | ||
end | ||
|
||
class InvalidFormat < Generic | ||
def initialize(content_filename) | ||
super("The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.") | ||
end | ||
end | ||
|
||
class UnparseableMetadata < Generic | ||
def initialize(filename, error) | ||
super("Could not parse metadata for #{filename}: #{error.message}") | ||
end | ||
end | ||
|
||
class InvalidMetadata < Generic | ||
def initialize(filename, klass) | ||
super("The file #{filename} has invalid metadata (expected key-value pairs, found #{klass} instead)") | ||
end | ||
end | ||
|
||
class InvalidEncoding < Generic | ||
def initialize(filename, encoding) | ||
super("Could not read #{filename} because the file is not valid #{encoding}.") | ||
end | ||
end | ||
|
||
class FileUnreadable < Generic | ||
def initialize(filename, error) | ||
super("Could not read #{filename}: #{error.inspect}") | ||
end | ||
end | ||
end | ||
end |
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