Skip to content

Commit bdb096d

Browse files
committed
Add: better parsing errors
1 parent 891829c commit bdb096d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Data/Schematic/Schema.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,22 @@ instance SingI schema => J.FromJSON (JsonRepr schema) where
454454
fieldRepr <- case s of
455455
SSchemaText so -> case H.lookup fieldName h of
456456
Just v -> withSingI so $ FieldRepr <$> parseJSON v
457-
Nothing -> fail "schematext"
457+
Nothing -> fail $ "No text field: " P.++ show fieldName
458458
SSchemaNumber so -> case H.lookup fieldName h of
459459
Just v -> withSingI so $ FieldRepr <$> parseJSON v
460-
Nothing -> fail "schemanumber"
460+
Nothing -> fail $ "No number field: " P.++ show fieldName
461461
SSchemaBoolean -> case H.lookup fieldName h of
462462
Just v -> FieldRepr <$> parseJSON v
463-
Nothing -> fail "schemaboolean"
463+
Nothing -> fail $ "No boolean field: " P.++ show fieldName
464464
SSchemaNull -> case H.lookup fieldName h of
465465
Just v -> FieldRepr <$> parseJSON v
466-
Nothing -> fail "schemanull"
466+
Nothing -> fail $ "No null field: " P.++ show fieldName
467467
SSchemaArray sa sb -> case H.lookup fieldName h of
468468
Just v -> withSingI sa $ withSingI sb $ FieldRepr <$> parseJSON v
469-
Nothing -> fail "schemaarray"
469+
Nothing -> fail $ "No array field: " P.++ show fieldName
470470
SSchemaObject so -> case H.lookup fieldName h of
471471
Just v -> withSingI so $ FieldRepr <$> parseJSON v
472-
Nothing -> fail "schemaobject"
472+
Nothing -> fail $ "No object field" P.++ show fieldName
473473
SSchemaOptional so -> case H.lookup fieldName h of
474474
Just v -> withSingI so $ FieldRepr <$> parseJSON v
475475
Nothing -> withSingI so $ pure $ FieldRepr $ ReprOptional Nothing

0 commit comments

Comments
 (0)