Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export exceptions to JS #167

Merged
merged 2 commits into from
May 22, 2024
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
6 changes: 3 additions & 3 deletions core/src/main/kotlin/Library.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import com.sdercolin.utaformatix.data.Document
import core.io.UfData
import core.model.ProjectContainer
import core.model.ExportResult
import core.model.Format
import core.model.ImportParams
import core.model.JapaneseLyricsType
import core.model.ProjectContainer
import core.process.lyrics.japanese.analyseJapaneseLyricsTypeForProject
import core.process.lyrics.japanese.convertJapaneseLyrics as convertJapaneseLyricsBase
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.promise
Expand All @@ -17,6 +16,7 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import org.w3c.files.File
import kotlin.js.Promise
import core.process.lyrics.japanese.convertJapaneseLyrics as convertJapaneseLyricsBase

@JsExport
fun parseVsqx(file: File): Promise<ProjectContainer> = parse(listOf(file), Format.Vsqx)
Expand Down Expand Up @@ -124,7 +124,7 @@ fun convertJapaneseLyrics(
project: ProjectContainer,
fromType: JapaneseLyricsType,
targetType: JapaneseLyricsType,
convertVowelConnections: Boolean
convertVowelConnections: Boolean,
): ProjectContainer {
val baseProject = project.project
val newProject = core.model.Project(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
class CannotReadFileException : Throwable()
2 changes: 2 additions & 0 deletions core/src/main/kotlin/core/exception/EmptyProjectException.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
class EmptyProjectException : Throwable("This format could not take en empty project.")
2 changes: 2 additions & 0 deletions core/src/main/kotlin/core/exception/IllegalFileException.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
sealed class IllegalFileException(message: String) : Throwable(message) {
class UnknownVsqVersion : IllegalFileException("Cannot identify the version of the loaded vsqx file.")
class XmlRootNotFound : IllegalFileException("The root element is not found in the xml file.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package core.exception

import core.model.Note

class IllegalNotePositionException(note: Note, trackIndex: Int) : Throwable(
@OptIn(ExperimentalJsExport::class)
@JsExport
class IllegalNotePositionException(@Suppress("NON_EXPORTABLE_TYPE") note: Note, trackIndex: Int) : Throwable(
"Failed to import because note with illegal position(${note.tickOn}) exists in Track No.${trackIndex + 1}",
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
class NotesOverlappingException : Throwable(
"Failed to process because there are notes overlapping with each other.",
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
open class UnsupportedFileFormatError : Exception()

@OptIn(ExperimentalJsExport::class)
@JsExport
class UnsupportedLegacyPpsfError : UnsupportedFileFormatError()
2 changes: 2 additions & 0 deletions core/src/main/kotlin/core/exception/ValueTooLargeException.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package core.exception

@OptIn(ExperimentalJsExport::class)
@JsExport
class ValueTooLargeException(value: String, maxValue: String) : Throwable(
"Given value $value is larger than the maximum: $maxValue.",
)
Loading