Skip to content

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

Description

@n4an

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)
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions