From 575d3f582674f5135cc084fb0f27250700f8a935 Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 25 Jul 2011 13:33:43 +0200 Subject: docview: -n parameter validation We now gracefully handle invalid -n parameter values, and notify the enduser of such a problem - instead of just crashing out. --- docview/src/frm_main.pas | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'docview') diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index e3617bd3..3c0590b5 100644 --- a/docview/src/frm_main.pas +++ b/docview/src/frm_main.pas @@ -3338,6 +3338,7 @@ procedure TMainForm.ProcessCommandLineParams; var showtopic: boolean; t: TTopic; + n: integer; begin if ParamCount > 0 then begin @@ -3368,8 +3369,17 @@ begin else if gCommandLineParams.IsParam('n') then begin { Display topic with numeric topic id } - t := FindTopicByResourceID(StrToInt(gCommandLineParams.GetParam('n'))); - DisplayTopic(t); + try + n := StrToInt(gCommandLineParams.GetParam('n')); + t := FindTopicByResourceID(n); + DisplayTopic(t); + except + on EConvertError do + begin + TfpgMessageDialog.Critical('Invalid Parameter Value', + '<' + gCommandLineParams.GetParam('n') + '> is not an number.'); + end; + end; end else if gCommandLineParams.IsParam('s') then begin -- cgit v1.2.3-70-g09d2