Skip to content

Commit

Permalink
feat: export EdgeError
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 19, 2024
1 parent c34d308 commit ef5dcbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Edge } from './src/edge/main.js'

export { EdgeError } from 'edge-error'
export { Template } from './src/template.js'
export { edgeGlobals } from './src/edge/globals.js'
export { Edge }
Expand Down
14 changes: 11 additions & 3 deletions src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,24 @@ export class Template extends Macroable {
}

/**
* Raise an error
* Creates an instance of the EdgeError
*/
newError(errorMessage: string, filename: string, lineNumber: number, column: number) {
throw new EdgeError(errorMessage, 'E_RUNTIME_EXCEPTION', {
createError(errorMessage: string, filename: string, lineNumber: number, column: number) {
return new EdgeError(errorMessage, 'E_RUNTIME_EXCEPTION', {
filename: filename,
line: lineNumber,
col: column,
})
}

/**
* Throws EdgeError. Use "createError" to create a new
* error instance
*/
newError(errorMessage: string, filename: string, lineNumber: number, column: number) {
throw this.createError(errorMessage, filename, lineNumber, column)
}

/**
* Rethrows the runtime exception by re-constructing the error message
* to point back to the original filename
Expand Down

0 comments on commit ef5dcbb

Please sign in to comment.