This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#135632495]
- Loading branch information
Konstantin Semenov
committed
Jan 20, 2017
1 parent
e212b68
commit 12bac76
Showing
5 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/io/pivotal/trilogy/application/ApplicationRunFailed.kt
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,3 @@ | ||
package io.pivotal.trilogy.application | ||
|
||
class ApplicationRunFailed : RuntimeException() |
22 changes: 21 additions & 1 deletion
22
src/main/kotlin/io/pivotal/trilogy/application/TrilogyApplication.kt
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 |
---|---|---|
@@ -1,17 +1,37 @@ | ||
package io.pivotal.trilogy.application | ||
|
||
import io.pivotal.trilogy.i18n.MessageCreator.createErrorMessage | ||
import org.springframework.beans.factory.UnsatisfiedDependencyException | ||
import org.springframework.boot.SpringApplication | ||
import org.springframework.boot.autoconfigure.SpringBootApplication | ||
import org.springframework.context.annotation.Import | ||
import java.net.ConnectException | ||
|
||
@SpringBootApplication | ||
@Import(TrilogyApplicationConfiguration::class) | ||
open class TrilogyApplication { | ||
|
||
|
||
companion object { | ||
@JvmStatic fun main(args: Array<String>) { | ||
SpringApplication.run(TrilogyApplication::class.java, *args) | ||
try { | ||
SpringApplication.run(TrilogyApplication::class.java, *args) | ||
} catch(e: IllegalStateException) { | ||
if (e.isCausedByConnectionFault) { | ||
println(createErrorMessage("connectionFailure", listOf("${e.cause}"))) | ||
} | ||
throw e | ||
} catch (e: UnsatisfiedDependencyException) { | ||
println(createErrorMessage("applicationUsage")) | ||
throw e | ||
} | ||
} | ||
|
||
private val Throwable.isCausedByConnectionFault: Boolean get() { | ||
return (this.cause?.cause is ConnectException) or (this.cause?.cause?.cause is ConnectException) | ||
} | ||
} | ||
|
||
} | ||
|
||
|
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
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