Skip to content

Networking category to @nativescript/core and added the docs for the Color, Connectivity, and HTTP modules as its subcategories. #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 106 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
87a6f6a
Added API description for the Payments: IAP & Subscriptions plugin
Jun 13, 2022
f9452d0
Added @nativescript/core subcategories names and their links.
Jun 18, 2022
ce4e1ed
I created the nativescript-core directory and moved the @nativescrip…
Ombuweb Jun 18, 2022
2c22083
Moved it to nativescript-core folder and added Connection Types info
Ombuweb Jun 18, 2022
7c39be2
Added the documentation for the subcategory
Ombuweb Jun 18, 2022
c7e2507
It was moved to nativescript-core folder
Ombuweb Jun 18, 2022
469929d
Removed broken/inconsistent links (API reference sections ) from http…
Ombuweb Jun 19, 2022
1505164
Added Application.android properties info
Ombuweb Jun 20, 2022
255d4a7
Added back API References section with full links
Ombuweb Jun 21, 2022
2f7ead2
Added back the API References section
Ombuweb Jun 21, 2022
c4250dc
Completed the docs of Android API part of the Application module
Ombuweb Jun 21, 2022
3aa4793
Added more content
Ombuweb Jun 22, 2022
a799594
Completed the Application module category
Ombuweb Jun 23, 2022
b7f931d
Remove the unnecessary flavor tabs
Ombuweb Jun 24, 2022
c3ffeb6
Merge remote-tracking branch 'origin/develop' into pr/87
NathanWalker Jul 8, 2022
15d397f
chore: adjusting header order and naming
NathanWalker Jul 8, 2022
9310ce5
Added ApplicationSettings link
Ombuweb Jul 9, 2022
7ee4567
Edited content
Ombuweb Jul 9, 2022
b809634
Editted content
Ombuweb Jul 9, 2022
2f9abb5
Completed the category
Ombuweb Jul 9, 2022
8624d72
Merge branch 'develop' of https://github.com/Ombuweb/docs-new into de…
Ombuweb Jul 9, 2022
bf24b88
Some FileSystem content
Ombuweb Jul 9, 2022
ca02558
Added Platform link
Ombuweb Jul 10, 2022
f676d76
Completed platform category
Ombuweb Jul 10, 2022
2970383
Some code tested, more testing to be done
Ombuweb Jul 10, 2022
8c1e8a0
Editted
Ombuweb Jul 11, 2022
cb19235
Fixed some broken links, more to be fixed
Ombuweb Jul 11, 2022
a404913
Completed
Ombuweb Jul 11, 2022
5e2d783
Completed
Ombuweb Jul 11, 2022
d368044
Added Screen class reference
Ombuweb Jul 11, 2022
6e7a1d4
Fixed all the broken links
Ombuweb Jul 11, 2022
0e9d8c7
Fixed all broken links( links to api-reference )
Ombuweb Jul 12, 2022
4b3e334
Refactored UI & Styling
Ombuweb Jul 12, 2022
6fff89e
Added some of the content
Ombuweb Jul 12, 2022
313fbbc
Done some Webpack refactoring
Ombuweb Jul 12, 2022
6f4ddca
Completed ImageSource
Ombuweb Jul 13, 2022
6003bd0
Added references
Ombuweb Jul 13, 2022
2f2645d
Fix
Ombuweb Jul 13, 2022
3cbfdd0
Added some content
Ombuweb Jul 13, 2022
663ce6f
Webpack refactoring completed
Ombuweb Jul 13, 2022
c364ddc
Completed
Ombuweb Jul 14, 2022
c41a916
Added Some content
Ombuweb Jul 15, 2022
86865b1
Added content. WIP
Ombuweb Jul 15, 2022
9f01b7d
Completed
Ombuweb Jul 16, 2022
98dbf64
Changed directory
Ombuweb Jul 16, 2022
b1bb704
Added some content
Ombuweb Jul 16, 2022
cce6530
Completed
Ombuweb Jul 17, 2022
4ecf540
Added some content
Ombuweb Jul 17, 2022
68db371
Completed
Ombuweb Jul 19, 2022
d4c6a86
Added some content and activated its link
Ombuweb Jul 19, 2022
241434e
Replaced a word
Ombuweb Jul 19, 2022
730cbdc
Added some content
Ombuweb Jul 20, 2022
89774df
completed
Ombuweb Jul 20, 2022
172d699
Content improved
Ombuweb Jul 20, 2022
c16ec69
Imporoved
Ombuweb Jul 21, 2022
c256567
Added some content
Ombuweb Jul 21, 2022
51da777
Modified the content
Ombuweb Jul 22, 2022
e23af69
Fixed broken links
Ombuweb Jul 22, 2022
feaa69d
Created this file
Ombuweb Jul 22, 2022
bef6a84
Updated content
Ombuweb Jul 22, 2022
a313aa8
Added some content
Ombuweb Jul 23, 2022
a258aae
completed
Ombuweb Jul 23, 2022
959bab4
Added some links and a new file
Ombuweb Jul 23, 2022
0b0a1f0
Updated
Ombuweb Jul 23, 2022
f9dd50e
Modified the trace module and added error handling file
Ombuweb Jul 24, 2022
38b6d5c
Polished
Ombuweb Jul 25, 2022
f83218a
Removed it, not necessary
Ombuweb Jul 25, 2022
fb607b5
Added the articles
Ombuweb Jul 27, 2022
f7937f5
Added these articles,to be completed
Ombuweb Jul 27, 2022
3a285ec
Added more content
Ombuweb Jul 28, 2022
8c1741d
Completed
Ombuweb Jul 29, 2022
1d53450
Added content and images
Ombuweb Jul 29, 2022
bf09eca
Corrected a tab
Ombuweb Jul 29, 2022
c763517
Added more content
Ombuweb Jul 31, 2022
db9be74
Added Nested Navigation content
Ombuweb Aug 1, 2022
05a75ae
Added some content
Ombuweb Aug 1, 2022
5ed6e40
Added content
Ombuweb Aug 2, 2022
fbd5304
Remove redundant link
Ombuweb Aug 2, 2022
cfd3794
Fixed the content
Ombuweb Aug 3, 2022
0351c3a
Added content
Ombuweb Aug 3, 2022
a2c8ed4
Rearranged content
Ombuweb Aug 3, 2022
b074e7b
Created this file
Ombuweb Aug 4, 2022
04b87f4
Added Memory Management link
Ombuweb Aug 4, 2022
665051e
Completed
Ombuweb Aug 6, 2022
dc8ee08
setup structure for "Components" docs. Added it to "nav" for providi…
Ombuweb Aug 9, 2022
1771ce5
Added corrected images
Ombuweb Aug 10, 2022
011b47a
Created the files and moved content to them from "components.md"
Ombuweb Aug 11, 2022
fdf9f72
Added and removed links
Ombuweb Aug 11, 2022
6405afa
Moved from "ui" folder to "components"
Ombuweb Aug 11, 2022
b46cee0
Created the files
Ombuweb Aug 13, 2022
e70cf86
Added content
Ombuweb Aug 13, 2022
e7ea4be
Updated
Ombuweb Aug 14, 2022
fd5f48d
fix: added Preview
Ombuweb Sep 19, 2022
72ae9df
fix: added Preview
Ombuweb Sep 19, 2022
9b96c59
fix: added Preview
Ombuweb Sep 19, 2022
f216f82
chore: clean up
Ombuweb Sep 19, 2022
59309c1
feat: added Preview
Ombuweb Sep 19, 2022
5a8a4e0
fix: python install correction
Ombuweb Oct 4, 2022
a5101c9
fix: referencing tailwind
Ombuweb Oct 5, 2022
4162fa0
fix: added new methods
Ombuweb Oct 5, 2022
788878b
fix: development workflow restructured and debugging WIP
Ombuweb Oct 17, 2022
2316296
chore: WIP only images left before it's completed
Ombuweb Oct 18, 2022
f18a02c
chore: done
Ombuweb Oct 18, 2022
d51c62e
chore: Corrected the nesting of the ON THIS PAGE links
Ombuweb Oct 18, 2022
a33eabb
fix: added image
Ombuweb Oct 19, 2022
486da62
feat: added the Fps Meter module
Ombuweb Oct 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Polished
  • Loading branch information
Ombuweb committed Jul 25, 2022
commit 38b6d5cad2e2111157c9a4516083bba3f5f435ca
58 changes: 54 additions & 4 deletions nativescript-core/trace.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,70 @@ Trace.addWriter(new TimestampConsoleWriter())

### Error handling

The Trace module also allows you to set a single error handler(`TraceErrorHandler`) to handle errors you capture with `Trace.error("Error messsage" | Error)` at different places in your app. You can read more about error handling in Nativescript at [Error Hnadling](/architecture-concepts/error-handling.md).
A big difference between web and NativeScript applications is the way the Errors are handled. Currently, when an unhandled exception is thrown in NativeScript, the app will crash, and an Error with the corresponding stack trace will be shown. In some cases, this seems to be the expected behaviour when the app is in **development** mode. You would want to have the stack trace of the exact location the unexpected error has occurred so that you can more easily understand what happened and fix the issue. However, when the app is in **production** similar application crashes can seriously hurt your application credibility and drive away customers. In many cases, you might prefer something else (e.g. app freeze, blank screen, failed navigation) to an actual crash with an error log.

Through the `Trace` module, Nativescript provides you with the ability to handle errors differently depending on whether the app is in **development** or **production** mode. When creating this module, the following 3 scenarios were taken into consideration:

1. (**development mode**) Throw exceptions as soon as an error occurs.
1. (**development mode**) Show a scary console.log with `"ERROR: Something bad happened"` but continue the execution of the app. You will see it in your terminal, but decide if it is critical based on what happens with the app after that.
1. (**production mode**) Send an error report to your analytics/error-report server but continue app execution. Maybe trigger some recover logic that will handle the app without a crash.

### Defining custom error handler

The default error handler will just throw the errors as they come. The following is a simple example showing how to define a custom handler to deal with the scenarios above:

```ts
const errorHandler: TraceErrorHandler = {
handlerError(error: Error) {
console.log(error.stack)
handlerError(err) {
// Option 1 (development) - throw the error
throw err

// Option 2 (development) - logging the error via write method provided from trace module
Trace.write(err, 'unhandled-error', type.error)

// (production) - custom functionality for error handling
// reportToAnalytics(err)
}
}

// Register errorHandler
Trace.setErrorHandler(errorHandler)
```

### Trace functionss
The `errorHandler` will be called whenever `Trace.error(...)` is called.

### Disabling rethrowing of uncaught JS exceptions to native

Nativescript provides developers with the property called `discardUncaughtJsExceptions` that allows you to configure whether unhandled exceptions coming from JavaScript code which has been called from the native platform should be caught or not. This option is disabled by default and to enable it you have to set the `discardUncaughtJsExceptions` property to `true` inside the `app/package.json` file.

Switching it on will cause JS exceptions to be caught without being propagated to the native world, effectively protecting the app from crashing. All discarded exceptions can be processed in the app by either subscribing to the `Application.discardedErrorEvent` and using the received `DiscardedErrorEventData` instance, or by assigning a one-argument function to `global.__onDiscardedError` which will receive the exception as a `NativeScriptError` instance. Usually you would want to log and/or report the exception to analytics.

<!--tabs: app/package.json -->

```json
{
"main": "app.js",
"discardUncaughtJsExceptions": true,
...
}
```

```ts
import { Application, DiscardedErrorEventData } from '@nativescript/core'

Application.on(Application.discardedErrorEvent, function (args: DiscardedErrorEventData) {
const error = args.error

console.log('Received discarded exception: ')
console.log(error.message)
console.log(error.name)
console.log(error.stack)
console.log(error.nativeError)
//report the exception in your analytics solution here
})
```

### Trace functions

| Name | Type | Description |
| ------------------------------------------------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down