-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lib): Extract Errors into its own module
- Loading branch information
1 parent
d33fc3b
commit 2c57d1d
Showing
4 changed files
with
33 additions
and
16 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,28 @@ | ||
module Data.Gibberish.Errors | ||
( GibberishErr (..), | ||
isTrigraphNotFound, | ||
isImpossibleError, | ||
) where | ||
|
||
import Control.Exception (Exception ()) | ||
import Data.Typeable (Typeable ()) | ||
|
||
-- | Exceptions that can occur at runtime | ||
data GibberishErr | ||
= TrigraphNotFound FilePath | ||
| ImpossibleError | ||
deriving stock (Eq, Typeable) | ||
|
||
instance Exception GibberishErr | ||
|
||
instance Show GibberishErr where | ||
show (TrigraphNotFound path) = "Trigraph file " <> show path <> " does not exist!" | ||
show ImpossibleError = "The impossible happened! Please file a bug report." | ||
|
||
isTrigraphNotFound :: GibberishErr -> Bool | ||
isTrigraphNotFound (TrigraphNotFound _) = True | ||
isTrigraphNotFound _ = False | ||
|
||
isImpossibleError :: GibberishErr -> Bool | ||
isImpossibleError ImpossibleError = True | ||
isImpossibleError _ = False |
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