From d4c2170b56b94497e37c94e5e3c9ee6f18a2ed43 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 14 Feb 2016 21:43:05 +0000 Subject: Some more useful constructors for PrintingError --- spec/src/Thermoprint/API.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'spec/src/Thermoprint/API.hs') 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 @@ {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-} {-# LANGUAGE TypeOperators, DataKinds #-} +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE OverloadedStrings #-} -- | A specification of an API for interacting with a set of printers @@ -59,8 +60,16 @@ data JobStatus = Queued PrinterId | Failed PrintingError deriving (Generic, Show, FromJSON, ToJSON) -data PrintingError = UnknownError - deriving (Typeable, Generic, NFData, Show, FromJSON, ToJSON, Exception) +deriving instance Generic EncodingException +deriving instance NFData EncodingException +deriving instance FromJSON EncodingException +deriving instance ToJSON EncodingException + +data PrintingError = IOError String -- ^ Not the actual error because we can't marshal that to JSON + | EncError EncodingException -- ^ Could not encode some part of the 'Printout' + deriving (Typeable, Generic, NFData, Show, FromJSON, ToJSON) + +instance Exception PrintingError type DraftTitle = Text -- cgit v1.2.3