File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
packages/live-elements-web-server/shared/errors Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 11import CSSError from "./css-error.mjs" ;
2+ import PublicError from "./public-error.mjs" ;
23import SourceError from "./source-error.mjs" ;
34import StandardError from "./standard-error.mjs" ;
45import TraceError from "./trace-error.mjs" ;
@@ -11,5 +12,6 @@ export default [
1112 CSSError ,
1213 SourceError ,
1314 TraceError ,
14- WorkerError
15+ WorkerError ,
16+ PublicError
1517]
Original file line number Diff line number Diff line change 1+ import StandardError from "./standard-error.mjs"
2+
3+ export default class PublicError extends StandardError {
4+ constructor ( message , internal ) {
5+ super ( message )
6+ this . _internal = internal
7+ this . name = this . constructor . name
8+ }
9+
10+ get internal ( ) { return this . _internal }
11+
12+ toJSON ( ) {
13+ return super . toJSON ( [ 'message' ] )
14+ }
15+
16+ static mask ( error , message ) {
17+ if ( error instanceof PublicError ) {
18+ return error
19+ } else {
20+ return new PublicError ( message , error )
21+ }
22+ }
23+
24+ static fromInternal ( error ) {
25+ return new PublicError ( error . message , error )
26+ }
27+
28+ static fromJSON ( json ) {
29+ return StandardError . __fromJSON ( json , PublicError )
30+ }
31+ }
You can’t perform that action at this time.
0 commit comments