aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-02-14 21:43:05 +0000
committerGregor Kleen <gkleen@yggdrasil.li>2016-02-14 21:43:05 +0000
commitd4c2170b56b94497e37c94e5e3c9ee6f18a2ed43 (patch)
treee6a84c523f38d4d723cf8f55457ea45ccbfd61e3
parent575a06949d7271734db4d52fe512981d6c0e139d (diff)
downloadthermoprint-d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43.tar
thermoprint-d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43.tar.gz
thermoprint-d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43.tar.bz2
thermoprint-d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43.tar.xz
thermoprint-d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43.zip
Some more useful constructors for PrintingError
-rw-r--r--server/test/Thermoprint/Server/QueueSpec.hs2
-rw-r--r--spec/src/Thermoprint/API.hs13
2 files changed, 12 insertions, 3 deletions
diff --git a/server/test/Thermoprint/Server/QueueSpec.hs b/server/test/Thermoprint/Server/QueueSpec.hs
index fd45e1b..c39083a 100644
--- a/server/test/Thermoprint/Server/QueueSpec.hs
+++ b/server/test/Thermoprint/Server/QueueSpec.hs
@@ -23,7 +23,7 @@ instance Arbitrary QueueEntry where
23 arbitrary = QueueEntry <$> arbitrary <*> arbitrary 23 arbitrary = QueueEntry <$> arbitrary <*> arbitrary
24 24
25instance Arbitrary PrintingError where 25instance Arbitrary PrintingError where
26 arbitrary = oneof [ return UnknownError 26 arbitrary = oneof [ return (IOError "dummy")
27 ] 27 ]
28 28
29instance Arbitrary JobId where 29instance Arbitrary JobId where
diff --git a/spec/src/Thermoprint/API.hs b/spec/src/Thermoprint/API.hs
index 6c020fc..6f7fc02 100644
--- a/spec/src/Thermoprint/API.hs
+++ b/spec/src/Thermoprint/API.hs
@@ -1,5 +1,6 @@
1{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-} 1{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
2{-# LANGUAGE TypeOperators, DataKinds #-} 2{-# LANGUAGE TypeOperators, DataKinds #-}
3{-# LANGUAGE StandaloneDeriving #-}
3{-# LANGUAGE OverloadedStrings #-} 4{-# LANGUAGE OverloadedStrings #-}
4 5
5-- | A specification of an API for interacting with a set of printers 6-- | A specification of an API for interacting with a set of printers
@@ -59,8 +60,16 @@ data JobStatus = Queued PrinterId
59 | Failed PrintingError 60 | Failed PrintingError
60 deriving (Generic, Show, FromJSON, ToJSON) 61 deriving (Generic, Show, FromJSON, ToJSON)
61 62
62data PrintingError = UnknownError 63deriving instance Generic EncodingException
63 deriving (Typeable, Generic, NFData, Show, FromJSON, ToJSON, Exception) 64deriving instance NFData EncodingException
65deriving instance FromJSON EncodingException
66deriving instance ToJSON EncodingException
67
68data PrintingError = IOError String -- ^ Not the actual error because we can't marshal that to JSON
69 | EncError EncodingException -- ^ Could not encode some part of the 'Printout'
70 deriving (Typeable, Generic, NFData, Show, FromJSON, ToJSON)
71
72instance Exception PrintingError
64 73
65type DraftTitle = Text 74type DraftTitle = Text
66 75