How do I raise an error from if activity in ADFV2?

I have found the easiest way to throw an error is to do a SQL lookup on the following query:

THROW 99999, 'Error message thrown', 1

For us, we make extensive use of Azure Function Apps, so we created a special function called "ThrowError" that throws an error with a message provided as a parameter. That is the easiest only if you already use Azure Function Apps, not worth it to just create the one function.


I have the similar scenario and I manage that with SqlStoreProcedure.

"storedProcedureName": "sp_executesql", "storedProcedureParameters": { "stmt": { "value": "Declare @err_msg NVARCHAR(150)SET @err_msg=N'Error occurred in this pipeline somehow somewhere something. Best regards. EXISTSCheers'RAISERROR(@err_msg,15,1)", "type": "string" } }

StoredProcedureName: sp_executesql

StoredProcedureParameter: stmt

Value: Declare @err_msg NVARCHAR (150) SET @err_msg=N'Error occurred in this pipeline somehow somewhere something. Best regards. EXISTSCheers'RAISERROR (@err_msg,15,1) (of course you can change error text:)

Type: string


I use a Set Variable Task to achieve this.

In the variable expression, I divide by zero. This throws an error which propigates up my pipeline(s) as needed. Most generic way I could think to do it.

"name": "Throw Error",
"description": "You can't throw an error in DF so I try to divide by zero. :)",
"type": "SetVariable",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
   "variableName": "ThrowError",
   "value": {
      "value": "@div(1,0)",
      "type": "Expression"
   }
}