This is still not quite right - the problem is that when the Error object is converted to JSON, the message is translated, so the error code is lost.
For example if the error was
message: validation.maxSize
key: provider.description
variables ["1024"]
Then when the Error object is created it will translate message into something like "The provider.description is more than 1024 chars".
So the resulting JSON will have the translated message:
{
message: "The provider.description is more than 1024 chars",
key: provider.description
variables ["1024"]
}
It would be nice to preserve the original error code as well, so that the client can take a different action depending on the type of error:
{
code: "validation.maxSize",
message: "The provider.description is more than 1024 chars",
key: provider.description
variables ["1024"]
}
This is still not quite right - the problem is that when the Error object is converted to JSON, the message is translated, so the error code is lost.
For example if the error was description
message: validation.maxSize
key: provider.
variables ["1024"]
Then when the Error object is created it will translate message into something like "The provider. description is more than 1024 chars". description is more than 1024 chars", description
So the resulting JSON will have the translated message:
{
message: "The provider.
key: provider.
variables ["1024"]
}
It would be nice to preserve the original error code as well, so that the client can take a different action depending on the type of error: maxSize" , description is more than 1024 chars", description
{
code: "validation.
message: "The provider.
key: provider.
variables ["1024"]
}