Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No context in bull exceptions handler like in default one. #102

Open
n4an opened this issue Feb 9, 2022 · 0 comments
Open

No context in bull exceptions handler like in default one. #102

n4an opened this issue Feb 9, 2022 · 0 comments

Comments

@n4an
Copy link

n4an commented Feb 9, 2022

No context in bull exceptions handler like in default one.

Add information about your environment

  • OS: Ubuntu
  • Node 16
  • Adonis 5

Additional context

import Logger from '@ioc:Adonis/Core/Logger'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'

Default  Adonis handler:

export default class ExceptionHandler extends HttpExceptionHandler {

  public async handle(error: any, ctx: HttpContextContract) {   // <----------- ctx
    /**
     * Forward rest of the exceptions to the parent class
     */
    return super.handle(error, ctx)
  }
}

Bull handler

import { LoggerContract } from '@ioc:Adonis/Core/Logger'
import { Job } from 'bullmq'

/**
 * Bull exception handler serves as the base exception handler
 * to handle all exceptions occured during the BULL queue execution
 * lifecycle and makes appropriate response for them.
 */
export abstract class BullExceptionHandler {
  constructor(protected logger: LoggerContract) {}

  public async handle(error: any, job: Job) {  // <------- no ctx
    if (typeof error.handle === 'function') {
      return error.handle(error, job)
    }
    this.logger.error(error.message)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant