File tree Expand file tree Collapse file tree
examples/consumer-test/src/main/kotlin/com/marketdata/examples Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,9 +14,11 @@ import com.marketdata.sdk.stocks.StockQuoteRequest
1414 * Run: `./gradlew runKotlinQuickstart`
1515 */
1616fun main () {
17- // `use {}` closes the client when the block ends — the Kotlin equivalent of try-with-resources.
18- MarketDataClient ().use { client ->
19- try {
17+ try {
18+ // `use {}` closes the client when the block ends — the Kotlin equivalent of try-with-resources.
19+ // Construction is inside the `try` so the no-arg constructor's startup validation (a real
20+ // `/user/` probe) is covered by the catch below on a missing/expired token.
21+ MarketDataClient ().use { client ->
2022 // Sync: blocks and returns the typed response.
2123 val quote = client.stocks().quote(StockQuoteRequest .of(" AAPL" )).values()[0 ]
2224 println (" Sync: ${quote.symbol()} last=${quote.last()} " )
@@ -27,8 +29,8 @@ fun main() {
2729 .quoteAsync(StockQuoteRequest .of(" AAPL" ))
2830 .thenAccept { resp -> println (" Async: ${resp.values()[0 ].last()} " ) }
2931 .join()
30- } catch (e: AuthenticationError ) {
31- println (" Set MARKETDATA_TOKEN (env var or .env) to run this example." )
3232 }
33+ } catch (e: AuthenticationError ) {
34+ println (" Set MARKETDATA_TOKEN (env var or .env) to run this example." )
3335 }
3436}
You can’t perform that action at this time.
0 commit comments