• Joseph Mckenzie 3
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Since visualForce doesn't have good  error handling for custom controllers, I am  writing some custom code show error messages.

My custom controller is editing a table.

In the code below, I am a trying to insert a line feed after every error using '\n'. 

However,  when error messages are output, there are no separate lines - it is one big error message. i have tried '\r' as well - doesn't work.

Any thoughts.

Code:
       } catch (DmlException e) {
for (Integer i = 0; i < e.getNumDml(); i++) { string[] fields = e.getDmlFields(i); //strip __c string field = fields[0].subString(0,fields[0].length()-3); integer row = e.getDmlIndex(i); String rowError = 'Row:' + (row+1) + ' Field:' + field + ':' + e.getDMLMessage(i); if (ErrorString[0] <> null) { ErrorString = ErrorString + '\n' + rowError; } else { ErrorString = 'ERROR:' + rowError + '\n'; } }