Skip to content

Throw Custom Error #30

@LeonardoGentile

Description

@LeonardoGentile

Hello, first of all thanks for this useful package 👍

Then, I'm running in couple of problems and I was wondering if someone had already went trough these:

  1. For some model I have a complex creation logic and I want so skip standard validation for some creation flows. For doing this I have custom beforeCreate or beforeValidate for some models. What I would like to do is to manually throw your "patched" validation error if some conditions occurs. Is it possible? How?

  2. In my controllers when I return a response in json I check whether or not there are errors. I check error.Errors in case a validation error occurs. But this is not always the case, and in many cases the structure of the errors messages are really different. How to manage this?
    So far I've came to a simple

var errors = err.Errors || err.message || "Unknown Error";
response.json(status, {'errors': errors});

but this is not always the case, because the structure of the error can change, depending on the type of error. I know it's a broad question but I was wondering if you already faced this kind of problems.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions