GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaScriptKit/Sources/JavaScriptKit/BasicObjects/JSError.swift at main · sakrist/JavaScriptKit

Expand file tree

/

JSError.swift

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
47 lines (39 loc) · 1.56 KB
/

JSError.swift

Copy path

File metadata and controls

47 lines (39 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/** A wrapper around [the JavaScript `Error`
class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) that
exposes its properties in a type-safe way.
*/
public final class JSError: Error, JSBridgedClass {
/// The constructor function used to create new JavaScript `Error` objects.
public static var constructor: JSFunction? { _constructor }
@LazyThreadLocal(initialize: { JSObject.global.Error.function })
private static var _constructor: JSFunction?
/// The underlying JavaScript `Error` object.
public let jsObject: JSObject
/// Creates a new instance of the JavaScript `Error` class with a given message.
public init(message: String) {
jsObject = Self.constructor!.new([message])
}
public init(unsafelyWrapping jsObject: JSObject) {
self.jsObject = jsObject
}
/// The error message of the underlying `Error` object.
public var message: String {
jsObject.message.string!
}
/// The name (usually corresponds to the name of the underlying class) of a given error.
public var name: String {
jsObject.name.string!
}
/// The JavaScript call stack that led to the creation of this error object.
public var stack: String? {
jsObject.stack.string
}
/// Creates a new `JSValue` from this `JSError` instance.
public var jsValue: JSValue {
.object(jsObject)
}
}
extension JSError: CustomStringConvertible {
/// The textual representation of this error.
public var description: String { jsObject.description }
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.