Skip to content

Commit 0df0367

Browse files
authored
Merge pull request #10 from arashi01/tausi_error_rename
Rename `TauriError` to `TausiError` to correctly match item semantics
2 parents 15c202c + 90992ab commit 0df0367

File tree

19 files changed

+242
-228
lines changed

19 files changed

+242
-228
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.*
2+
*.md
3+
!README.md
4+
!.github/
5+
!.scalafix.conf
6+
!.scalafmt.conf
7+
8+
dist/
9+
node_modules/
10+
target/
11+
**/src-tauri/gen/
12+
metals.sbt

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ import zio.*
117117
import tausi.zio.*
118118
import tausi.api.commands.window.{given, *}
119119

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

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

202202
// Tier 3: Full state (recommended for production)
203203
val stateSignal: Signal[StreamState[Int]] = counter.toStateSignal
@@ -209,7 +209,7 @@ The `StreamState` ADT provides full lifecycle visibility:
209209
enum StreamState[+A]:
210210
case Running // Stream is loading
211211
case Value(value: A) // Latest value received
212-
case Failed(error: TauriError) // Stream failed
212+
case Failed(error: TausiError) // Stream failed
213213
case Completed // Stream completed (no final value)
214214
case CompletedWith(value: A) // Stream completed with final value
215215
```

modules/api/js/src/main/scala/tausi/api/PluginRegistry.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ object PluginRegistry:
106106
* @param ec Execution context
107107
* @return Future containing a list of plugin initialization errors (empty if all succeeded)
108108
*/
109-
def initializeAll(using ExecutionContext): Future[List[TauriError.PluginError]] =
109+
def initializeAll(using ExecutionContext): Future[List[TausiError.PluginError]] =
110110
val pluginsToInit = plugins.values.toList.filter(!_.initialized)
111111

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

142142
Future
@@ -148,7 +148,7 @@ object PluginRegistry:
148148
None
149149
}
150150
.recover { case e =>
151-
Some(TauriError.PluginError(entry.name, s"Failed to shutdown: ${e.getMessage}", Some(e)))
151+
Some(TausiError.PluginError(entry.name, s"Failed to shutdown: ${e.getMessage}", Some(e)))
152152
}
153153
}
154154
}

modules/api/js/src/main/scala/tausi/api/Resource.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object Resource:
4343
* After closing, the resource cannot be used.
4444
*
4545
* @param ec Execution context for async operations
46-
* @return Future containing Either a TauriError or Unit
46+
* @return Future containing Either a TausiError or Unit
4747
*/
4848
def close()(using ec: ExecutionContext): Future[Unit] =
4949
// Import core in method to avoid circular dependency

modules/api/js/src/main/scala/tausi/api/TauriError.scala renamed to modules/api/js/src/main/scala/tausi/api/TausiError.scala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ import scala.scalajs.js
2424
import scala.util.control.NoStackTrace
2525

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

33-
object TauriError:
33+
object TausiError:
3434
/** Error occurred during command invocation.
3535
*
3636
* @param command The command name that was invoked
@@ -41,7 +41,7 @@ object TauriError:
4141
command: String,
4242
message: String,
4343
cause: Option[Throwable] = None
44-
) extends TauriError(message, cause)
44+
) extends TausiError(message, cause)
4545

4646
/** Error occurred during plugin operations.
4747
*
@@ -53,7 +53,7 @@ object TauriError:
5353
plugin: String,
5454
message: String,
5555
cause: Option[Throwable] = None
56-
) extends TauriError(message, cause)
56+
) extends TausiError(message, cause)
5757

5858
/** Error occurred during permission operations.
5959
*
@@ -63,7 +63,7 @@ object TauriError:
6363
final case class PermissionError(
6464
message: String,
6565
cause: Option[Throwable] = None
66-
) extends TauriError(message, cause)
66+
) extends TausiError(message, cause)
6767

6868
/** Error occurred during resource management.
6969
*
@@ -75,7 +75,7 @@ object TauriError:
7575
resourceId: ResourceId,
7676
message: String,
7777
cause: Option[Throwable] = None
78-
) extends TauriError(message, cause)
78+
) extends TausiError(message, cause)
7979

8080
/** Error occurred during file path conversion.
8181
*
@@ -89,7 +89,7 @@ object TauriError:
8989
protocol: String,
9090
message: String,
9191
cause: Option[Throwable] = None
92-
) extends TauriError(message, cause)
92+
) extends TausiError(message, cause)
9393

9494
/** Error occurred during callback operations.
9595
*
@@ -101,7 +101,7 @@ object TauriError:
101101
callbackId: CallbackId,
102102
message: String,
103103
cause: Option[Throwable] = None
104-
) extends TauriError(message, cause)
104+
) extends TausiError(message, cause)
105105

106106
/** Error occurred during channel operations.
107107
*
@@ -113,7 +113,7 @@ object TauriError:
113113
channelId: CallbackId,
114114
message: String,
115115
cause: Option[Throwable] = None
116-
) extends TauriError(message, cause)
116+
) extends TausiError(message, cause)
117117

118118
/** Error occurred during stream operations.
119119
*
@@ -123,7 +123,7 @@ object TauriError:
123123
final case class StreamError(
124124
message: String,
125125
cause: Option[Throwable] = None
126-
) extends TauriError(message, cause)
126+
) extends TausiError(message, cause)
127127

128128
/** Error occurred during event operations.
129129
*
@@ -135,7 +135,7 @@ object TauriError:
135135
eventName: String,
136136
message: String,
137137
cause: Option[Throwable] = None
138-
) extends TauriError(message, cause)
138+
) extends TausiError(message, cause)
139139

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

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

158158
object InvokeError:
159159
/** Create InvokeError without cause */
@@ -212,8 +212,8 @@ object TauriError:
212212
"Tauri runtime is not available. Ensure this code runs within a Tauri application."
213213
)
214214

215-
extension (error: TauriError)
216-
/** Extract human-readable error message from any TauriError variant. */
215+
extension (error: TausiError)
216+
/** Extract human-readable error message from any TausiError variant. */
217217
inline def message: String = error match
218218
case e: InvokeError => e.message
219219
case e: PluginError => e.message
@@ -227,7 +227,7 @@ object TauriError:
227227
case e: GenericError => e.message
228228
case e: TauriNotAvailableError => e.message
229229

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

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

257-
/** Wrap JavaScript error into a TauriError.
257+
/** Wrap JavaScript error into a TausiError.
258258
*
259259
* Handles various JavaScript error representations safely.
260260
*
261261
* @param error The JavaScript error object
262262
* @param context Descriptive context for error message
263263
* @return GenericError wrapping the JS error
264264
*/
265-
def fromJSError(error: Any, context: String): TauriError =
265+
def fromJSError(error: Any, context: String): TausiError =
266266
error match
267267
case e: js.JavaScriptException =>
268268
GenericError(s"$context: ${e.getMessage}", Some(e))
@@ -273,5 +273,5 @@ object TauriError:
273273
case _ =>
274274
GenericError(s"$context: Unknown JavaScript error", None)
275275

276-
given CanEqual[TauriError, TauriError] = CanEqual.derived
277-
end TauriError
276+
given CanEqual[TausiError, TausiError] = CanEqual.derived
277+
end TausiError

0 commit comments

Comments
 (0)