Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.*
*.md
!README.md
!.github/
!.scalafix.conf
!.scalafmt.conf

dist/
node_modules/
target/
**/src-tauri/gen/
metals.sbt
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ import zio.*
import tausi.zio.*
import tausi.api.commands.window.{given, *}

val program: ZIO[Any, TauriError, Unit] = for
val program: ZIO[Any, TausiError, Unit] = for
_ <- invoke(SetTitle("main", "My App"))
_ <- invoke(SetSize("main", 1024, 768))
_ <- ZIO.log("Window configured")
Expand Down Expand Up @@ -196,8 +196,8 @@ val counter: ZStreamIO[Int] = ZStream.iterate(0)(_ + 1).take(10)
val eventStream: EventStream[Int] = counter.toStreamUnsafe

// Tier 2: Either-based (errors as values)
val signal: Signal[Either[TauriError, Int]] =
counter.toSignal(Left(TauriError.StreamError("Loading...")))
val signal: Signal[Either[TausiError, Int]] =
counter.toSignal(Left(TausiError.StreamError("Loading...")))

// Tier 3: Full state (recommended for production)
val stateSignal: Signal[StreamState[Int]] = counter.toStateSignal
Expand All @@ -209,7 +209,7 @@ The `StreamState` ADT provides full lifecycle visibility:
enum StreamState[+A]:
case Running // Stream is loading
case Value(value: A) // Latest value received
case Failed(error: TauriError) // Stream failed
case Failed(error: TausiError) // Stream failed
case Completed // Stream completed (no final value)
case CompletedWith(value: A) // Stream completed with final value
```
Expand Down
8 changes: 4 additions & 4 deletions modules/api/js/src/main/scala/tausi/api/PluginRegistry.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ object PluginRegistry:
* @param ec Execution context
* @return Future containing a list of plugin initialization errors (empty if all succeeded)
*/
def initializeAll(using ExecutionContext): Future[List[TauriError.PluginError]] =
def initializeAll(using ExecutionContext): Future[List[TausiError.PluginError]] =
val pluginsToInit = plugins.values.toList.filter(!_.initialized)

Future
Expand All @@ -118,7 +118,7 @@ object PluginRegistry:
None
}
.recover { case e =>
Some(TauriError.PluginError(entry.name, s"Failed to initialize: ${e.getMessage}", Some(e)))
Some(TausiError.PluginError(entry.name, s"Failed to initialize: ${e.getMessage}", Some(e)))
}
}
}
Expand All @@ -136,7 +136,7 @@ object PluginRegistry:
* @param ec Execution context
* @return Future containing a list of plugin shutdown errors (empty if all succeeded)
*/
def shutdownAll(using ExecutionContext): Future[List[TauriError.PluginError]] =
def shutdownAll(using ExecutionContext): Future[List[TausiError.PluginError]] =
val pluginsToShutdown = plugins.values.toList.filter(_.initialized).reverse

Future
Expand All @@ -148,7 +148,7 @@ object PluginRegistry:
None
}
.recover { case e =>
Some(TauriError.PluginError(entry.name, s"Failed to shutdown: ${e.getMessage}", Some(e)))
Some(TausiError.PluginError(entry.name, s"Failed to shutdown: ${e.getMessage}", Some(e)))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/api/js/src/main/scala/tausi/api/Resource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object Resource:
* After closing, the resource cannot be used.
*
* @param ec Execution context for async operations
* @return Future containing Either a TauriError or Unit
* @return Future containing Either a TausiError or Unit
*/
def close()(using ec: ExecutionContext): Future[Unit] =
// Import core in method to avoid circular dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import scala.scalajs.js
import scala.util.control.NoStackTrace

/** The root error type for all Tauri-related errors. */
sealed abstract class TauriError(message: String, cause: Option[Throwable])
sealed abstract class TausiError(message: String, cause: Option[Throwable])
extends Throwable(message, cause.getOrElse(null.asInstanceOf[Throwable]))
with NoStackTrace
with Product
with Serializable // scalafix:ok

object TauriError:
object TausiError:
/** Error occurred during command invocation.
*
* @param command The command name that was invoked
Expand All @@ -41,7 +41,7 @@ object TauriError:
command: String,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during plugin operations.
*
Expand All @@ -53,7 +53,7 @@ object TauriError:
plugin: String,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during permission operations.
*
Expand All @@ -63,7 +63,7 @@ object TauriError:
final case class PermissionError(
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during resource management.
*
Expand All @@ -75,7 +75,7 @@ object TauriError:
resourceId: ResourceId,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during file path conversion.
*
Expand All @@ -89,7 +89,7 @@ object TauriError:
protocol: String,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during callback operations.
*
Expand All @@ -101,7 +101,7 @@ object TauriError:
callbackId: CallbackId,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during channel operations.
*
Expand All @@ -113,7 +113,7 @@ object TauriError:
channelId: CallbackId,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during stream operations.
*
Expand All @@ -123,7 +123,7 @@ object TauriError:
final case class StreamError(
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error occurred during event operations.
*
Expand All @@ -135,7 +135,7 @@ object TauriError:
eventName: String,
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Generic error for cases not covered by specific error types.
*
Expand All @@ -145,15 +145,15 @@ object TauriError:
final case class GenericError(
message: String,
cause: Option[Throwable] = None
) extends TauriError(message, cause)
) extends TausiError(message, cause)

/** Error indicating Tauri runtime is not available.
*
* This typically occurs when code is run outside a Tauri application.
*
* @param message Description of what went wrong
*/
final case class TauriNotAvailableError(message: String) extends TauriError(message, None)
final case class TauriNotAvailableError(message: String) extends TausiError(message, None)

object InvokeError:
/** Create InvokeError without cause */
Expand Down Expand Up @@ -212,8 +212,8 @@ object TauriError:
"Tauri runtime is not available. Ensure this code runs within a Tauri application."
)

extension (error: TauriError)
/** Extract human-readable error message from any TauriError variant. */
extension (error: TausiError)
/** Extract human-readable error message from any TausiError variant. */
inline def message: String = error match
case e: InvokeError => e.message
case e: PluginError => e.message
Expand All @@ -227,7 +227,7 @@ object TauriError:
case e: GenericError => e.message
case e: TauriNotAvailableError => e.message

/** Extract optional underlying cause from any TauriError variant. */
/** Extract optional underlying cause from any TausiError variant. */
inline def cause: Option[Throwable] = error match
case e: InvokeError => e.cause
case e: PluginError => e.cause
Expand All @@ -246,23 +246,23 @@ object TauriError:
// Helper Constructors
// ====================

/** Wrap any Throwable into a TauriError.
/** Wrap any Throwable into a TausiError.
*
* Returns the input unchanged if already a TauriError, otherwise wraps in [[GenericError]].
* Returns the input unchanged if already a TausiError, otherwise wraps in [[GenericError]].
*/
inline def fromThrowable(t: Throwable): TauriError = t match
case e: TauriError => e
inline def fromThrowable(t: Throwable): TausiError = t match
case e: TausiError => e
case e => GenericError(s"Unexpected error: ${e.getMessage}", Some(e))

/** Wrap JavaScript error into a TauriError.
/** Wrap JavaScript error into a TausiError.
*
* Handles various JavaScript error representations safely.
*
* @param error The JavaScript error object
* @param context Descriptive context for error message
* @return GenericError wrapping the JS error
*/
def fromJSError(error: Any, context: String): TauriError =
def fromJSError(error: Any, context: String): TausiError =
error match
case e: js.JavaScriptException =>
GenericError(s"$context: ${e.getMessage}", Some(e))
Expand All @@ -273,5 +273,5 @@ object TauriError:
case _ =>
GenericError(s"$context: Unknown JavaScript error", None)

given CanEqual[TauriError, TauriError] = CanEqual.derived
end TauriError
given CanEqual[TausiError, TausiError] = CanEqual.derived
end TausiError
Loading