Formatting strings using scripted fields - inserting line breaks

I've tried scripted fields, I've used lang=painless, type=string, format=string,
script=/\n/.matcher(doc['message'].value).replaceAll('
')

but then I receive this error
"Courier Fetch: 10 of 715 shards failed.

The script might be written wrong...

I've tried

  1. doc['message'].value = "\n" + "

  2. /\n/.matcher(doc['message'].value).replaceAll('
    ')

Wondering how I can debug or test a scripted field......