Construct the error message. This will be prefixed with "Error: " when it is returned to the user.
| 55 | |
| 56 | // Construct the error message. This will be prefixed with "Error: " when it is returned to the user. |
| 57 | void GCodeException::GetMessage(const StringRef &reply, const GCodeBuffer *null gb) const noexcept |
| 58 | { |
| 59 | // Print the file location, if possible |
| 60 | switch(source) |
| 61 | { |
| 62 | case GCodeExceptionSource::file: |
| 63 | reply.copy("in GCode file"); |
| 64 | break; |
| 65 | case GCodeExceptionSource::macro: |
| 66 | reply.copy("in file macro"); |
| 67 | break; |
| 68 | case GCodeExceptionSource::other: |
| 69 | default: |
| 70 | break; |
| 71 | } |
| 72 | |
| 73 | if (line >= 0) |
| 74 | { |
| 75 | reply.catf(" line %d", line); |
| 76 | if (column >= 0) |
| 77 | { |
| 78 | reply.catf(" column %d", column + 1); |
| 79 | } |
| 80 | reply.cat(": "); |
| 81 | } |
| 82 | else if (column >= 0) |
| 83 | { |
| 84 | reply.catf(" at column %d: ", column + 1); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | reply.Clear(); |
| 89 | } |
| 90 | |
| 91 | // Print the command letter/number, if possible |
| 92 | if (gb != nullptr) |
| 93 | { |
| 94 | switch (gb->GetCommandLetter()) |
| 95 | { |
| 96 | case 'E': |
| 97 | reply.cat("meta command: "); |
| 98 | break; |
| 99 | |
| 100 | case 'G': |
| 101 | case 'M': |
| 102 | case 'T': |
| 103 | if (gb->HasCommandNumber()) |
| 104 | { |
| 105 | if (gb->GetCommandFraction() >= 0) |
| 106 | { |
| 107 | reply.catf("%c%d.%d: ", gb->GetCommandLetter(), gb->GetCommandNumber(), gb->GetCommandFraction()); |
| 108 | |
| 109 | } |
| 110 | else |
| 111 | { |
| 112 | reply.catf("%c%d: ", gb->GetCommandLetter(), gb->GetCommandNumber()); |
| 113 | } |
| 114 | } |
no test coverage detected