# Setting Crash SDK

## 1. Detailed setting

### Setting the collection server

{% hint style="warning" %}
Clients who have selected an installation-type must perform this setting.
{% endhint %}

The collection server can be set separately, which sends data to be collected by the IMQA Crash framework. Basically, no separate settings are required for clients using SaaS.<br>

**Objective-C**

{% code title="AppDelegate.m" %}

```swift
NSString* imqaUrl = @"https://custom-url";
IMQACrashConfiguration* crashConfig = [[IMQACrashConfiguration alloc] initWithApiKey:PROJECT_KEY];

IMQACrashEndpointConfiguration* endpoint = [[IMQACrashEndpointConfiguration alloc] init];
endpoint.notify = [imqaUrl stringByAppendingString:@"/cocoa/crash/send"];
endpoint.sessions = [imqaUrl stringByAppendingString:@"/cocoa/session"];
crashConfig.endpoints = endpoint;


```

{% endcode %}

**Swift**

{% code title="AppDelegate.swift" %}

```swift
let imqaUrl = "https://custom-url"
let crashConfig = IMQACrashConfiguration("<PROJECT_KEY>")
crashConfig.endpoints = IMQACrashEndpointConfiguration(
                                 notify: imqaUrl + "/cocoa/crash/send",
                                 sessions: imqaUrl + "/cocoa/session")
```

{% endcode %}

## 2. Sending custom errors

IMQA Crash enables you to manually send custom errors. You can send various network errors or errors you wish to collect directly to our server using NSError for tracking.

**Objective-C**

{% code title="AppDelegate.m" %}

```
#import <IMQACrashAgent/IMQACrash.h>

NSError* custom_error = [NSError errorWithDomain:@"custom_error" code:404 userInfo:NULL];
[IMQACrash notifyError:custom_error];
```

{% endcode %}

**Swift**

{% code title="AppDelegate.swift" %}

```swift
let custom_error = NSError(domain: "custom error", code: 404, userInfo: nil)
IMQACrash.notifyError(custom_error)
```

{% endcode %}

## 3. Custom Web Crash

IMQA WebAgent lets you collect custom errors by specifying the desired error messages for detailed web error analytics.

{% hint style="warning" %}
To collect Webview Crash, you must add ImqaBridgeCrash. Please refer to '[iOS > Setting MPM SDK > Setting WKWebView > Setting iOS project](/imqa-guide/eng/installation-guide/ios/setting-mpm-sdk.md#ios-project-setting)'.
{% endhint %}

### Create Custom Errors

IMQA WCrash detects and collects user-defined errors.

{% hint style="warning" %}
Different errors but of the same error type are recognized as the same error, which can lead to error accumulation.
{% endhint %}

### Custom Error Messages

You can change the default error messages to any error messages you want and collect them by WebAgent. We recommend specifying several error messages for detailed web error analytics.

{% hint style="warning" %}
If you specify error messages, even errors of the same type will be collected as different errors.
{% endhint %}

{% code title="JS files to collect custom errors" %}

```javascript
...
// When using try-catch
try {
	...
}
catch(e){
	throw new Error("Custom error messages");
}

// When to generate default errors
new Error("Custom error messages");
```

{% endcode %}

You can view web crashes with detailed information in the IMQA WCrash service as shown below.

<figure><img src="https://lh7-us.googleusercontent.com/CW4QD8o6NvrtFpAORvtdBUR8Cxbht1HyBEAsmolCEGG1hyJ13RrUbqbF7KWB62PqL0BPg5hFbHqFjRJYtOaS8E9PVRdiuwIT93NGZN53NRITlp5cVNOei4TgQP5SVOHkUBqVVjL99rlmKYS88hPiS30" alt=""><figcaption></figcaption></figure>

**❶ Caught Error Instance Type**\
Displays the name of the caught error instance of the error if it is generated on a web page.

**❷ Custom Error Message**\
Displays a user-specified message when a specific error-type error is generated.

```javascript
throw new Error("Custom error messages");
```

**❸ Error type / Code line number**\
You can check the type of webview error and the line number of the error.

<table><thead><tr><th width="202" align="center">Error type</th><th align="center">Description</th></tr></thead><tbody><tr><td align="center">Error</td><td align="center">This is the error type set by the user.</td></tr><tr><td align="center">EvalError</td><td align="center">This error occurs in <mark style="color:red;">eval()</mark>.</td></tr><tr><td align="center">RangeError</td><td align="center">This error is generated when a variable is outside its valid range.</td></tr><tr><td align="center">ReferenceError</td><td align="center">This error occurs when an incorrect reference is made.</td></tr><tr><td align="center">SyntaxError</td><td align="center">It is an error if incorrect syntax exists.</td></tr><tr><td align="center">TypeError</td><td align="center">If it is not a valid data type, it is a type error.</td></tr><tr><td align="center">URIError</td><td align="center">This error is generated when inappropriate parameters are passed to the <mark style="color:red;">encodeURI()</mark> or <mark style="color:red;">decodeURI()</mark> functions.</td></tr><tr><td align="center">AggregateError</td><td align="center">This is a type of error that wraps multiple errors into one error.</td></tr></tbody></table>

## 4. dSYM Settings

For apps with iOS Symbolication, you can view class names and function names through dSYM settings. See [Using MPM > Project list > Project Management > ProGuard / dSYM settings](/imqa-guide/eng/user-guide/using-mpm/project-list.md#proguard-dsym-settings).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imqa.io/imqa-guide/eng/installation-guide/ios/crash-sdk-setting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
