How to use badRequest in a custom service context?

Hello… I’m creating a custom service and I’m not able to use the badRequest within the service, is there any way to import or use it in some context? Thanks.

Here is an example I use inside the controller:

      if (!data?.email) {
        return context.badRequest('email is missing!', {
          data: {
            email: 'your email'
          }
        });
      }

I’m abstracting the logic for the service, but I don’t have access to my context.

I found the solution in the personal documentation, the record is here:

The service should not have access to the ctx/context object. This is the controller’s responsibility. I think the best way would be to throw an error from the service, catch it in the controller, and then use ctx.BadRequest when catching the error.

That’s right, throwing the error I was already able to get the error message I needed. Thank you for your help. :slight_smile: