web 3d图形渲染器
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.

21 lines
697 B

  1. 'use strict'
  2. module.exports = Base => class extends Base {
  3. warn (code, message, data = {}) {
  4. if (this.file)
  5. data.file = this.file
  6. if (this.cwd)
  7. data.cwd = this.cwd
  8. data.code = message instanceof Error && message.code || code
  9. data.tarCode = code
  10. if (!this.strict && data.recoverable !== false) {
  11. if (message instanceof Error) {
  12. data = Object.assign(message, data)
  13. message = message.message
  14. }
  15. this.emit('warn', data.tarCode, message, data)
  16. } else if (message instanceof Error)
  17. this.emit('error', Object.assign(message, data))
  18. else
  19. this.emit('error', Object.assign(new Error(`${code}: ${message}`), data))
  20. }
  21. }