You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be a sizable undertaking, but I think should be considered. I've come across a situation in which one particular error of a few that may be returned by ORM is OK. However, the only way to identify that error is by the string message. There should be some other more stable identifying piece of information such as an error code, in addition to the messages.
For example, the Model function get(id, callback) can throw a few errors, some of which are, missing callback; key length mismatches; or, my allowable error, a not found error. The only identifiable information available is the "Not found" string in the error object. One solution is to extend the error object into a generic ORM error object that will contain the message and a code.
Ok, I clearly see your point. You would like to have a way of distinguishing the errors without parsing a string (that might change). We have to identify them and create codes for them, perhaps having a global orm file with the list of codes (that people can lookup) and orm will use. I have to create a basic one, perhaps starting with the Model.get.
Activity
dresende commentedon Jun 22, 2013
Can you show me an example of such error?
jogly commentedon Jun 23, 2013
Gladly :)
For example, the Model function
get(id, callback)can throw a few errors, some of which are, missing callback; key length mismatches; or, my allowable error, a not found error. The only identifiable information available is the "Not found" string in the error object. One solution is to extend the error object into a generic ORM error object that will contain the message and a code.Now, we can use
throw new ORMError("Same message", NEW_CODE);, or create reusable errors:This is something that could be phased in without affecting any existing code since every custom error will already effectively be an error.
dresende commentedon Jun 24, 2013
Ok, I clearly see your point. You would like to have a way of distinguishing the errors without parsing a string (that might change). We have to identify them and create codes for them, perhaps having a global orm file with the list of codes (that people can lookup) and orm will use. I have to create a basic one, perhaps starting with the
Model.get.Changes many errors to use the ErrorCodes generator (#206)
dresende commentedon Jun 27, 2013
There should be more missing errors there, I have to change all of them. If you find any, feel free to change it.
Changes more errors to use the new ErrorCodes generator (#206)
dresende commentedon Jun 27, 2013
I think I added most of them. If you find any please reopen.