davidm-db commented on code in PR #47537:
URL: https://github.com/apache/spark/pull/47537#discussion_r1697234609


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/errors/SqlScriptingException.scala:
##########
@@ -17,40 +17,77 @@
 
 package org.apache.spark.sql.errors
 
-import org.apache.spark.SparkException
+import org.apache.spark.{SparkException, SparkThrowableHelper}
+import org.apache.spark.sql.catalyst.trees.Origin
+import 
org.apache.spark.sql.errors.SqlScriptingException.errorMessageWithLineNumber
+
+class SqlScriptingException protected (
+    origin: Origin,
+    errorClass: String,
+    cause: Throwable,
+    messageParameters: Map[String, String] = Map.empty)
+  extends SparkException(
+    message = errorMessageWithLineNumber(origin, errorClass, 
messageParameters),
+    errorClass = Option(errorClass),
+    cause = cause,
+    messageParameters = messageParameters
+  ) {
+
+}
 
 /**
  * Object for grouping error messages thrown during parsing/interpreting phase
  * of the SQL Scripting Language interpreter.
  */
-private[sql] object SqlScriptingErrors extends QueryErrorsBase {
+private[sql] object SqlScriptingException {
 
-  def labelsMismatch(beginLabel: String, endLabel: String): Throwable = {
-    new SparkException(
+  def labelsMismatch(origin: Origin, beginLabel: String, endLabel: String): 
Throwable = {
+    new SqlScriptingException(
+      origin = origin,
       errorClass = "LABELS_MISMATCH",
       cause = null,
       messageParameters = Map("beginLabel" -> beginLabel, "endLabel" -> 
endLabel))
   }
 
-  def endLabelWithoutBeginLabel(endLabel: String): Throwable = {
-    new SparkException(
+  def endLabelWithoutBeginLabel(origin: Origin, endLabel: String): Throwable = 
{
+    new SqlScriptingException(
+      origin = origin,
       errorClass = "END_LABEL_WITHOUT_BEGIN_LABEL",
       cause = null,
       messageParameters = Map("endLabel" -> endLabel))
   }
 
-  def variableDeclarationNotAllowedInScope(varName: String, lineNumber: 
String): Throwable = {
-    new SparkException(
+  def variableDeclarationNotAllowedInScope(
+    origin: Origin,
+    varName: String,
+    lineNumber: String
+  ): Throwable = {
+    new SqlScriptingException(
+      origin = origin,
       errorClass = "INVALID_VARIABLE_DECLARATION.NOT_ALLOWED_IN_SCOPE",
       cause = null,
       messageParameters = Map("varName" -> varName, "lineNumber" -> 
lineNumber))
   }
 
-  def variableDeclarationOnlyAtBeginning(varName: String, lineNumber: String): 
Throwable = {
-    new SparkException(
+  def variableDeclarationOnlyAtBeginning(
+    origin: Origin,

Review Comment:
   we usually indent parameters for 4 spaces, and lines in the function for 2 
spaces, so when you apply all the comments, this function should look like
   ```
   def variableDeclarationOnlyAtBeginning(
       origin: Origin,
       varName: String,
       lineNumber: String): Throwable = {
     new SqlScriptingException(...)
   }
   ```
   
   same goes for other functions in this file



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to