diff --git a/Data/ASN1/BinaryEncoding/Parse.hs b/Data/ASN1/BinaryEncoding/Parse.hs
--- a/Data/ASN1/BinaryEncoding/Parse.hs
+++ b/Data/ASN1/BinaryEncoding/Parse.hs
@@ -124,7 +124,7 @@
                                                             , remBytes)
            go (ParseState stackEnd (ExpectPrimitive len cont) pos) bs =
                 case runGetPrimitive cont len pos bs of
-                     Fail _               -> error "primitive parsing failed"
+                     Fail _               -> Left ParsingPartial
                      Partial f            -> Right (([], ParseState stackEnd (ExpectPrimitive len $ Just f) pos), B.empty)
                      Done p nPos remBytes -> Right (([Primitive p], ParseState stackEnd (ExpectHeader Nothing) nPos), remBytes)
 
diff --git a/Data/ASN1/Error.hs b/Data/ASN1/Error.hs
--- a/Data/ASN1/Error.hs
+++ b/Data/ASN1/Error.hs
@@ -25,6 +25,7 @@
                | ParsingPartial              -- ^ Parsing is not finished, there is construction unended.
                | TypeNotImplemented String   -- ^ Decoding of a type that is not implemented. Contribution welcome.
                | TypeDecodingFailed String   -- ^ Decoding of a knowed type failed.
+               | TypePrimitiveInvalid String -- ^ Invalid primitive type
                | PolicyFailed String String -- ^ Policy failed including the name of the policy and the reason.
                deriving (Typeable, Show, Eq)
 
diff --git a/Data/ASN1/Prim.hs b/Data/ASN1/Prim.hs
--- a/Data/ASN1/Prim.hs
+++ b/Data/ASN1/Prim.hs
@@ -169,8 +169,8 @@
 decodePrimitive (ASN1Header Universal 0xb _ _) _   = Left $ TypeNotImplemented "EMBEDDED PDV"
 decodePrimitive (ASN1Header Universal 0xc _ _) p   = getCharacterString UTF8 p
 decodePrimitive (ASN1Header Universal 0xd _ _) _   = Left $ TypeNotImplemented "RELATIVE-OID"
-decodePrimitive (ASN1Header Universal 0x10 _ _) _  = error "sequence not a primitive"
-decodePrimitive (ASN1Header Universal 0x11 _ _) _  = error "set not a primitive"
+decodePrimitive (ASN1Header Universal 0x10 _ _) _  = Left $ TypePrimitiveInvalid "sequence"
+decodePrimitive (ASN1Header Universal 0x11 _ _) _  = Left $ TypePrimitiveInvalid "set"
 decodePrimitive (ASN1Header Universal 0x12 _ _) p  = getCharacterString Numeric p
 decodePrimitive (ASN1Header Universal 0x13 _ _) p  = getCharacterString Printable p
 decodePrimitive (ASN1Header Universal 0x14 _ _) p  = getCharacterString T61 p
diff --git a/Data/ASN1/Serialize.hs b/Data/ASN1/Serialize.hs
--- a/Data/ASN1/Serialize.hs
+++ b/Data/ASN1/Serialize.hs
@@ -37,7 +37,7 @@
 getTagLong :: Get ASN1Tag
 getTagLong = do
     t <- fromIntegral <$> getWord8
-    when (t == 0x80) $ error "not canonical encoding of tag"
+    when (t == 0x80) $ fail "non canonical encoding of long tag"
     if testBit t 7
         then loop (clearBit t 7)
         else return t
diff --git a/asn1-encoding.cabal b/asn1-encoding.cabal
--- a/asn1-encoding.cabal
+++ b/asn1-encoding.cabal
@@ -1,5 +1,5 @@
 Name:                asn1-encoding
-Version:             0.9.4
+Version:             0.9.5
 Synopsis:            ASN1 data reader and writer in RAW, BER and DER forms
 Description:
     ASN1 data reader and writer in raw form with supports for high level forms of ASN1 (BER, and DER).
