Mirror of github.com/gissleh/irc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
625 B

6 years ago
6 years ago
6 years ago
  1. package irc
  2. // NewErrorEvent makes an event of kind `error` and verb `code` with the text.
  3. // It's absolutely trivial, but it's good to have standarized.
  4. func NewErrorEvent(code, text, i18nKey string, raw error) Event {
  5. return NewErrorEventTarget(nil, code, text, i18nKey, raw)
  6. }
  7. func NewErrorEventTarget(target Target, code, text, i18nKey string, raw error) Event {
  8. event := NewEvent("error", code)
  9. event.Text = text
  10. if target != nil {
  11. event.targets = append(event.targets, target)
  12. }
  13. if i18nKey != "" {
  14. event.Tags["i18n_key"] = i18nKey
  15. }
  16. if raw != nil {
  17. event.Tags["raw"] = raw.Error()
  18. }
  19. return event
  20. }