-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
30 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
flint-commons/src/main/scala/org/apache/spark/sql/exception/UnrecoverableException.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql.exception | ||
|
||
class UnrecoverableException private (message: String, cause: Throwable) | ||
extends RuntimeException(message, cause) { | ||
|
||
def this(cause: Throwable) = | ||
this(cause.getMessage, cause) | ||
} | ||
|
||
object UnrecoverableException { | ||
def apply(cause: Throwable): UnrecoverableException = | ||
new UnrecoverableException(cause) | ||
|
||
def apply(message: String, cause: Throwable): UnrecoverableException = | ||
new UnrecoverableException(message, cause) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
spark-sql-application/src/main/scala/org/apache/spark/sql/util/ExceptionHandler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.apache.spark.sql.util | ||
|
||
import org.apache.spark.internal.Logging | ||
|
||
class ExceptionHandler extends Logging { | ||
private var _exceptionThrown: Option[Throwable] = None | ||
private var _error: String = _ | ||
|
||
def exceptionThrown: Option[Throwable] = _exceptionThrown | ||
def error: String = _error | ||
|
||
def handleException(err: String, e: Throwable): Unit = { | ||
_error = err | ||
_exceptionThrown = Some(e) | ||
logError(err, e) | ||
} | ||
|
||
def setError(err: String): Unit = { | ||
_error = err | ||
} | ||
|
||
def reset(): Unit = { | ||
_exceptionThrown = None | ||
_error = null | ||
} | ||
|
||
def hasException: Boolean = _exceptionThrown.isDefined | ||
} |