From 73ea786721f56b4fc6662c9631e9224f32f6de85 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 14 Nov 2010 18:14:14 +0100 Subject: [PATCH] Help UDC identifying the location of the bug for AvalonEdit ArgumentOutOfRangeExceptions. --- .../Editor/AvalonEdit/AvalonEditDocumentAdapter.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs index d7fd0f7ba1..1c31e665ff 100644 --- a/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs +++ b/src/Main/Base/Project/Src/Editor/AvalonEdit/AvalonEditDocumentAdapter.cs @@ -112,12 +112,22 @@ namespace ICSharpCode.SharpDevelop.Editor.AvalonEdit public int PositionToOffset(int line, int column) { - return document.GetOffset(new TextLocation(line, column)); + try { + return document.GetOffset(new TextLocation(line, column)); + } catch (ArgumentOutOfRangeException e) { + // for UDC: re-throw exception so that stack trace identifies the caller (instead of the adapter) + throw new ArgumentOutOfRangeException(e.ParamName, e.ActualValue, e.Message); + } } public Location OffsetToPosition(int offset) { - return ToLocation(document.GetLocation(offset)); + try { + return ToLocation(document.GetLocation(offset)); + } catch (ArgumentOutOfRangeException e) { + // for UDC: re-throw exception so that stack trace identifies the caller (instead of the adapter) + throw new ArgumentOutOfRangeException(e.ParamName, e.ActualValue, e.Message); + } } public static Location ToLocation(TextLocation position)