| 49 | } |
| 50 | |
| 51 | func (er ExportResult) String() string { |
| 52 | switch er.Event { |
| 53 | case ExportEventBug: |
| 54 | return fmt.Sprintf("[%s] new issue: %s", er.EntityId.Human(), er.EntityId) |
| 55 | case ExportEventComment: |
| 56 | return fmt.Sprintf("[%s] new comment", er.EntityId.Human()) |
| 57 | case ExportEventCommentEdition: |
| 58 | return fmt.Sprintf("[%s] updated comment", er.EntityId.Human()) |
| 59 | case ExportEventStatusChange: |
| 60 | return fmt.Sprintf("[%s] changed status", er.EntityId.Human()) |
| 61 | case ExportEventTitleEdition: |
| 62 | return fmt.Sprintf("[%s] changed title", er.EntityId.Human()) |
| 63 | case ExportEventLabelChange: |
| 64 | return fmt.Sprintf("[%s] changed label", er.EntityId.Human()) |
| 65 | case ExportEventNothing: |
| 66 | if er.EntityId != "" { |
| 67 | return fmt.Sprintf("no actions taken on entity %s: %s", er.EntityId, er.Reason) |
| 68 | } |
| 69 | return fmt.Sprintf("no actions taken: %s", er.Reason) |
| 70 | case ExportEventError: |
| 71 | if er.EntityId != "" { |
| 72 | return fmt.Sprintf("export error on entity %s: %s", er.EntityId, er.Err.Error()) |
| 73 | } |
| 74 | return fmt.Sprintf("export error: %s", er.Err.Error()) |
| 75 | case ExportEventWarning: |
| 76 | if er.EntityId != "" { |
| 77 | return fmt.Sprintf("warning on entity %s: %s", er.EntityId, er.Err.Error()) |
| 78 | } |
| 79 | return fmt.Sprintf("warning: %s", er.Err.Error()) |
| 80 | case ExportEventRateLimiting: |
| 81 | return fmt.Sprintf("rate limiting: %s", er.Reason) |
| 82 | |
| 83 | default: |
| 84 | panic("unknown export result") |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | func NewExportError(err error, entityId entity.Id) ExportResult { |
| 89 | return ExportResult{ |