3
I have a Tigger for CPF validation, and I want to make an exception if the reported CPF is invalid.
About the release of exceptions I’ve been reading this publishing, but in the author’s examples he simply makes an exception that already exists in the system (Division by zero) and simply relaunches this exception.
But what I want is to cast a new exception, an exception that doesn’t exist in the system, like, an exception CpfInvalid
.
I understand the questions of making the validations in the application. But, take up the theme of about doing this in db. I see no reason to use
BEGIN TRY END TRY
because you yourself cited an exception ofCpfInvalido
does not exist in SQL Server, I already knew that. I do not see pq useBEGIN TRY END TRY
for the same reason I find the examples of the publication I quoted unfortunate. That is, in the example of the publication the author does not make any treatment, only relaunches the exception with an extra text. As in Sqlserver there is no exception forCpfInvalid
TRY CATCH
is useless. cont.....– Matheus Saraiva
I don’t want to treat an exception that doesn’t exist, I just want to launch one, and let it explode in the app.
– Matheus Saraiva
@Matheussaraiva , RAISERROR may return an error message.
– Marco Souza
@Matheussaraiva, Returns beautiful messages in the application are not a good, it would only hide the real error that is occurring, the way that Altor does, described in the question is not wrong, it returns the exception correctly, there is no error in it.
– Marco Souza
In my understanding what the author does is just capture and relaunch. Isn’t that the same as not doing any treatment?
RAISERROR
I have seen that he is depreciated and being replaced byTHROW
, where the doc claims to have three parameterserror_number
message
andstate
.&#My question now is whether the values oferror_number
andstate
are free choice programmer.– Matheus Saraiva
@Matheussaraiva, are not well of free choice, the ERROR_NUMBER is captured in the treatment block as well as the ERROR_MESSAGE and the ERROR_STATE, but you can show message the way you want, but as I said earlier it would only hide the real error.
– Marco Souza