public void LineExceptionTest_Message_ErrorResponse() { var json = @" { ""message"":""The request body has 2 error(s)"", ""details"":[ { ""message"":""May not be empty"", ""property"":""messages[0].text"" }, { ""message"":""Must be one of the following values: [text, image, video, audio, location, sticker, template, imagemap]"", ""property"":""messages[1].type"" } ] }"; var res = JsonConvert.DeserializeObject <ErrorResponse>(json); var ex = new LineException("message", res); var expected = "message\nThe request body has 2 error(s)\n messages[0].text: May not be empty\n messages[1].type: Must be one of the following values: [text, image, video, audio, location, sticker, template, imagemap]"; Assert.AreEqual(expected, ex.Message); }
public static void ShowLineError(LineException ex) { MessageBox.Show(String.Format( "An error occured at line {0}:\r\n{1}\r\n\r\nSource:\r\n{2}", (ex.LineIndex + 1).ToString(), ex.InnerException.Message, ex.Line ), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void ShowLineErrorInTextBox(LineException ex) { ShowLineError(ex); int lineStart; int lineStop; try { lineStart = textBox.GetFirstCharIndexFromLine(ex.LineIndex); } catch { lineStart = 0; } try { lineStop = textBox.GetFirstCharIndexFromLine(ex.LineIndex + 1); } catch { lineStop = -1; } if (lineStop == -1) { lineStop = textBox.TextLength; } else { lineStop -= 2; } textBox.Select(); textBox.Select(lineStart, lineStop - lineStart); }
public void LineExceptionTest_Message() { var ex = new LineException("message"); Assert.AreEqual("message", ex.Message); }