Skip to content

Error() should word-wrap error messages, not break them in the middle of a word #1197

Open
@fingolfin

Description

From a comment by @james-d-mitchell on issue #1195:

Error, IsomorphismTransformationMonoid: usage, the argument must be a semigroup w
ith a multiplicative neutral element, at /Users/jdm/gap/lib/semitran.gi:360 call
ed from
<function "unknown">( <arguments> )
 called from read-eval loop at *stdin*:2
type 'quit;' to quit to outer loop
brk>

Note how the word "with" is split after the "w". Here is an experiment I just did myself:

gap> Error("This is a very long text. Bla bla. More word. and it is present in one of the GAP root directories. and it is present in one of the GAP root directories");
Error, This is a very long text. Bla bla. More word. and it is present in one of the GAP root directori\
es. and it is present in one of the GAP root directories called from
not in any function at *stdin*:1
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk>

Note how this is not only breaking the message in the middle of a word (though at least with a \ indicating this), but it also breaks too late, and thus we end up with a very short text line between two longer ones (my guess is that GAP fails to take the string Error, into account for the wrapping).

Both of these issues should be fixed. Here is a suggestion:

  1. First try to break at a whitespace;
  2. if that fails, fallback to breaking after non-letter/digit symbols;
  3. if that fails, fallback to breaking anywhere.

The wrapping indicator \ probably should only be shown in the last case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    kind: bugIssues describing general bugs, and PRs fixing themkind: enhancementLabel for issues suggesting enhancements; and for pull requests implementing enhancementstopic: error handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions