Skip to content

Commit

Permalink
Drop InvalidDsnException.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed May 7, 2021
1 parent 71eca42 commit 3da98b1
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 55 deletions.
Expand Up @@ -6,7 +6,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import com.nhaarman.mockitokotlin2.mock
import io.sentry.ILogger
import io.sentry.Sentry
import io.sentry.exception.InvalidDsnException
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertFailsWith
Expand Down Expand Up @@ -93,7 +92,7 @@ class SentryInitProviderTest {

metaData.putString(ManifestMetadataReader.DSN, "invalid dsn")

assertFailsWith<InvalidDsnException> { sentryInitProvider.attachInfo(mockContext, providerInfo) }
assertFailsWith<IllegalArgumentException> { sentryInitProvider.attachInfo(mockContext, providerInfo) }
}

@Test
Expand Down
8 changes: 0 additions & 8 deletions sentry/api/sentry.api
Expand Up @@ -1255,14 +1255,6 @@ public final class io/sentry/exception/ExceptionMechanismException : java/lang/R
public fun isSnapshot ()Z
}

public final class io/sentry/exception/InvalidDsnException : java/lang/RuntimeException {
public fun <init> (Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
public fun <init> (Ljava/lang/String;Ljava/lang/Throwable;)V
public fun getDsn ()Ljava/lang/String;
}

public final class io/sentry/exception/InvalidSentryTraceHeaderException : java/lang/Exception {
public fun <init> (Ljava/lang/String;)V
public fun getSentryTraceHeader ()Ljava/lang/String;
Expand Down
5 changes: 2 additions & 3 deletions sentry/src/main/java/io/sentry/Dsn.java
@@ -1,6 +1,5 @@
package io.sentry;

import io.sentry.exception.InvalidDsnException;
import java.net.URI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -48,7 +47,7 @@ URI getSentryUri() {
return sentryUri;
}

Dsn(@Nullable String dsn) throws InvalidDsnException {
Dsn(@Nullable String dsn) throws IllegalArgumentException {
try {
URI uri = new URI(dsn).normalize();
String userInfo = uri.getUserInfo();
Expand Down Expand Up @@ -85,7 +84,7 @@ URI getSentryUri() {
null,
null);
} catch (Exception e) {
throw new InvalidDsnException(dsn, e);
throw new IllegalArgumentException(e);
}
}
}
32 changes: 0 additions & 32 deletions sentry/src/main/java/io/sentry/exception/InvalidDsnException.java

This file was deleted.

8 changes: 4 additions & 4 deletions sentry/src/test/java/io/sentry/DsnTest.kt
@@ -1,6 +1,6 @@
package io.sentry

import io.sentry.exception.InvalidDsnException
import java.lang.IllegalArgumentException
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
Expand Down Expand Up @@ -59,19 +59,19 @@ class DsnTest {

@Test
fun `when no project id exists, throws exception`() {
val ex = assertFailsWith<InvalidDsnException> { Dsn("http://key@host/") }
val ex = assertFailsWith<IllegalArgumentException> { Dsn("http://key@host/") }
assertEquals("java.lang.IllegalArgumentException: Invalid DSN: A Project Id is required.", ex.message)
}

@Test
fun `when no key exists, throws exception`() {
val ex = assertFailsWith<InvalidDsnException> { Dsn("http://host/id") }
val ex = assertFailsWith<IllegalArgumentException> { Dsn("http://host/id") }
assertEquals("java.lang.IllegalArgumentException: Invalid DSN: No public key provided.", ex.message)
}

@Test
fun `when only passing secret key, throws exception`() {
val ex = assertFailsWith<InvalidDsnException> { Dsn("https://:secret@host/path/id") }
val ex = assertFailsWith<IllegalArgumentException> { Dsn("https://:secret@host/path/id") }
assertEquals("java.lang.IllegalArgumentException: Invalid DSN: No public key provided.", ex.message)
}

Expand Down
3 changes: 1 addition & 2 deletions sentry/src/test/java/io/sentry/HubTest.kt
Expand Up @@ -14,7 +14,6 @@ import com.nhaarman.mockitokotlin2.times
import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import com.nhaarman.mockitokotlin2.whenever
import io.sentry.exception.InvalidDsnException
import io.sentry.hints.SessionEndHint
import io.sentry.hints.SessionStartHint
import io.sentry.protocol.SentryId
Expand Down Expand Up @@ -487,7 +486,7 @@ class HubTest {
fun `when captureUserFeedback is called and client throws, don't crash`() {
val (sut, mockClient) = getEnabledHub()

whenever(mockClient.captureUserFeedback(any())).doThrow(InvalidDsnException(""))
whenever(mockClient.captureUserFeedback(any())).doThrow(IllegalArgumentException(""))

sut.captureUserFeedback(userFeedback)
}
Expand Down
3 changes: 1 addition & 2 deletions sentry/src/test/java/io/sentry/RequestDetailsResolverTest.kt
@@ -1,6 +1,5 @@
package io.sentry

import io.sentry.exception.InvalidDsnException
import java.net.URL
import kotlin.test.Test
import kotlin.test.assertEquals
Expand All @@ -11,7 +10,7 @@ class RequestDetailsResolverTest {

@Test
fun `When options doesn't have a valid DSN, it throws InvalidDsnException`() {
assertFailsWith<InvalidDsnException> { RequestDetailsResolver(SentryOptions()).resolve() }
assertFailsWith<IllegalArgumentException> { RequestDetailsResolver(SentryOptions()).resolve() }
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/test/java/io/sentry/SentryClientTest.kt
Expand Up @@ -12,7 +12,6 @@ import com.nhaarman.mockitokotlin2.verify
import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions
import com.nhaarman.mockitokotlin2.verifyZeroInteractions
import com.nhaarman.mockitokotlin2.whenever
import io.sentry.exception.InvalidDsnException
import io.sentry.exception.SentryEnvelopeException
import io.sentry.hints.ApplyScopeData
import io.sentry.hints.Cached
Expand All @@ -31,6 +30,7 @@ import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.io.InputStreamReader
import java.lang.IllegalArgumentException
import java.lang.IllegalStateException
import java.lang.RuntimeException
import java.nio.charset.Charset
Expand Down Expand Up @@ -99,7 +99,7 @@ class SentryClientTest {
fun `when dsn is an invalid string, client throws`() {
fixture.sentryOptions.setTransportFactory(NoOpTransportFactory.getInstance())
fixture.sentryOptions.dsn = "invalid-dsn"
assertFailsWith<InvalidDsnException> { fixture.getSut() }
assertFailsWith<IllegalArgumentException> { fixture.getSut() }
}

@Test
Expand Down

0 comments on commit 3da98b1

Please sign in to comment.