From c55038ed170b207910296643cc151eece1358892 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Fri, 15 Jun 2018 14:20:05 +0900 Subject: [PATCH] Rescue Fluent::ConfigError Signed-off-by: Kenji Okimoto --- app/controllers/api_controller.rb | 2 ++ app/javascript/packs/in_tail_parse.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 24ea265..11445a0 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -23,6 +23,8 @@ class ApiController < ApplicationController preview = RegexpPreview.processor(params[:parse_type]).new(params[:file], params[:parse_type], plugin_config) render json: preview.matches + rescue Fluent::ConfigError => ex + render json: { error: "#{ex.class}: #{ex.message}" } end def grok_to_regexp diff --git a/app/javascript/packs/in_tail_parse.js b/app/javascript/packs/in_tail_parse.js index 60124bd..9cf205a 100644 --- a/app/javascript/packs/in_tail_parse.js +++ b/app/javascript/packs/in_tail_parse.js @@ -139,7 +139,12 @@ $(document).ready(() => { } }).then( (result) => { - this.updateHighlightedLines(result.matches) + if (result.matches) { + this.updateHighlightedLines(result.matches) + } else { + console.error(result.error) + this.previewError = result.error + } }, (error) => { this.highlightedLines = null