From 83ce370a768f9aafe0077cfc034d6562f797bcdc Mon Sep 17 00:00:00 2001 From: Watson Date: Sun, 22 Feb 2015 15:18:24 +0900 Subject: [PATCH] better error message handling --- command/utils.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/command/utils.rb b/command/utils.rb index 29c23fc..3a1ca76 100644 --- a/command/utils.rb +++ b/command/utils.rb @@ -73,16 +73,18 @@ def password def parse_nslog_message(message) messages = [] - message.split("\n").each do |msg| + tmp = message.split("\n") + tmp.shift if tmp[0].end_with?("Error: (") + tmp.each do |msg| msg.strip! if m = msg.match(/(No errors.+)/) # success messages << m[1] - elsif m = msg.match(/^"Error Domain=[^"]+"(.+)\\" UserInfo=.+/) + elsif m = msg.match(/NSLocalizedDescription=(.+), NSLocalizedFailureReason=/) # error messages << m[1] elsif m = msg.match(/(Error:.+)/) - # other errors (password error...) + # other errors messages << m[1] end end