# Suggestion: produce a meaningful error when the serializer can't be determined

**URL:** <https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307>\
**Category:** General Discussion\
**Created:** [June 14, 2011, 10:22pm UTC](https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307 "2011-06-14T22:22:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew.geery](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@andrew.geery](https://forum.liquibase.org/u/andrew.geery)\
**Post date:** [June 14, 2011, 10:22pm UTC](https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307/1 "2011-06-14T22:22:00Z")

</div>

I was running the generateChangeLog command and I ran into the following error:

INFO 6/14/11 10:15 AM:liquibase: c:\temp\test.diff exists, appending

Liquibase Update Failed: Unknown Reason

SEVERE 6/14/11 10:15 AM:liquibase: Unknown Reason

java.lang.NullPointerException

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:507)

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:426)

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.diff.DiffResult.printChangeLog(DiffResult.java:406)

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:151)

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.integration.commandline.Main.doMigration(Main.java:624)

&nbsp; &nbsp; &nbsp; &nbsp; at liquibase.integration.commandline.Main.main(Main.java:116)

I checked out the code and ran it through the debugger. &nbsp;I found that the serializer is determined from the file extension of the --changeLogFile parameter. &nbsp;As I walked through the code in the debugger, there are two serializers set up: xml and txt. &nbsp;If you provide a different extension for the output file (as I did), you’ll get a NPE as above because the code on line 405 in&nbsp;liquibase.diff.DiffResult will return null:

ChangeLogSerializer changeLogSerializer = serializerFactory.getSerializer(changeLogFile);

I would suggest doing the one of the following:

1. at the very least, check after line 405 and make sure the serializer isn’t null – throw an exception with a meaningful message if it is – even better (because sooner), as part of the validation of the command-line arguments, make sure the given extension is valid; or

2. perhaps change the SerializerFactory to default to either the xml or txt serializer if one can’t be found for the given extension

I’d be happy to submit a patch if it would help – let me know!

Thanks for the great tool!

Andrew

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [June 14, 2011, 10:22pm UTC](https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307/2 "2011-06-14T22:22:00Z")

</div>

A better error message would definitely be good. &nbsp;If you wanted to submit a patch, that would be great

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [June 14, 2011, 10:22pm UTC](https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307/3 "2011-06-14T22:22:00Z")

</div>

Thanks! I applied the change.

Nathan

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [June 14, 2011, 10:22pm UTC](https://forum.liquibase.org/t/suggestion-produce-a-meaningful-error-when-the-serializer-cant-be-determined/1307/4 "2011-06-14T22:22:00Z")

</div>

I attached a git diff to provide a better error message. &nbsp;The change is in the ChangeLogSerializerFactory. &nbsp;If serializers.get(fileNameOrExtension) returns null, the getSerializer method throws a RuntimeException with the message that there is no serializer for the filename or extension.

Thanks

Andrew
