Mercurial > prosody-hg
comparison net/server_epoll.lua @ 10991:aa85cb5b859f
net.server_epoll: Allow setting a custom error handler for listener
This lets plugins handle errors in some custom way, should they wish to.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 30 Jun 2020 17:35:07 +0200 |
| parents | 03e76ad725b2 |
| children | df3ee12acd8c |
comparison
equal
deleted
inserted
replaced
| 10990:03e76ad725b2 | 10991:aa85cb5b859f |
|---|---|
| 190 local listener = self.listeners["on"..what]; | 190 local listener = self.listeners["on"..what]; |
| 191 if not listener then | 191 if not listener then |
| 192 self:noise("Missing listener 'on%s'", what); -- uncomment for development and debugging | 192 self:noise("Missing listener 'on%s'", what); -- uncomment for development and debugging |
| 193 return; | 193 return; |
| 194 end | 194 end |
| 195 local ok, err = xpcall(listener, traceback, self, ...); | 195 local onerror = self.listeners.onerror or traceback; |
| 196 local ok, err = xpcall(listener, onerror, self, ...); | |
| 196 if not ok then | 197 if not ok then |
| 197 if cfg.fatal_errors then | 198 if cfg.fatal_errors then |
| 198 self:error("Closing due to error calling on%s: %s", what, err); | 199 self:error("Closing due to error calling on%s: %s", what, err); |
| 199 self:destroy(); | 200 self:destroy(); |
| 200 else | 201 else |
