Skip to content

Commit

Permalink
feat: new public method to allow sending simple strings (#122)
Browse files Browse the repository at this point in the history
* And new public method to allow sending simple strings.

* Doc update
  • Loading branch information
TheRealAgentK authored Oct 13, 2024
1 parent 5bb4865 commit ad51374
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ The following methods are available for sending manually; pick one depending on
* `RaygunClient.send(Throwable throwable)`
* `RaygunClient.send(Throwable throwable, List tags)`
* `RaygunClient.send(Throwable throwable, List tags, Map customData)`
* `RaygunClient.send(String exceptionName, String reason, List tags, Map customData)`

The `send` function builds a RaygunMessage for you and then sends it.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class MainActivity : AppCompatActivity() {
null,
tw,
)

// Manual exception creation & sending via 2 strings
RaygunClient.send("My custom message", "The reason for the error", null, tw)

Snackbar.make(
it,
getString(R.string.you_have_just_sent_an_error_with_raygun4android),
Expand Down
19 changes: 19 additions & 0 deletions provider/src/main/java/com/raygun/raygun4android/RaygunClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ public static void send(Throwable throwable, List tags, Map customData) {
CrashReporting.send(throwable, tags, customData);
}

/**
* Sends an exception name and reason to Raygun by constructing a Throwable object from it. Adds
* a list of tags you specify, and a set of custom data.
*
* @param exceptionName The name or description of the exception that occurred in your
* application that will be sent to Raygun.
* @param reason The reason for the exception that occurred in your application that will be
* sent to Raygun.
* @param tags A list of data that will be attached to the Raygun message and visible on the
* error in the dashboard. This could be a build tag, lifecycle state, debug/production
* version etc.
* @param customData A set of custom key-value pairs relating to your application and its
* current state. This is a bucket where you can attach any related data you want to see to
* the error.
*/
public static void send(String exceptionName, String reason, List tags, Map customData) {
CrashReporting.send(new Throwable(exceptionName, new Throwable(reason)), tags, customData);
}

/**
* Sets the current user of your application. If user is an email address which is associated
* with a Gravatar, their picture will be displayed in the error view. If setUser is not called,
Expand Down

0 comments on commit ad51374

Please sign in to comment.