From f467dbbaded5ddf5b059b9b000096363e3287e0f Mon Sep 17 00:00:00 2001 From: Nikolay Bobrovskiy Date: Mon, 27 Nov 2017 03:20:44 +0300 Subject: [PATCH] Fixes #1067 --- src/Serilog/Parsing/MessageTemplateParser.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Serilog/Parsing/MessageTemplateParser.cs b/src/Serilog/Parsing/MessageTemplateParser.cs index 7a9e1003c..644697e60 100644 --- a/src/Serilog/Parsing/MessageTemplateParser.cs +++ b/src/Serilog/Parsing/MessageTemplateParser.cs @@ -133,11 +133,8 @@ static MessageTemplateToken ParsePropertyToken(int startAt, string messageTempla if (lastDash > 0) return new TextToken(rawText, first); - var width = lastDash == -1 ? - int.Parse(alignment) : - int.Parse(alignment.Substring(1)); - - if (width == 0) + var width = 0; + if (!int.TryParse(lastDash == -1 ? alignment : alignment.Substring(1), out width) || width == 0) return new TextToken(rawText, first); var direction = lastDash == -1 ?