Packhouse
  • Introduction
  • Versions
  • Core
    • Group
      • Mold
      • Tool
      • Line
    • Invoke
    • Utils
    • Event
    • Merger
    • Plugin
    • Main
    • Intercept Error
  • Plugins
    • Step
    • Order
  • Tooling
    • Unit Test
  • Application
    • API Service
  • From
    • GitHub
    • Metal Sheep
Powered by GitBook
On this page

Was this helpful?

  1. Core

Intercept Error

Intercept Error

Intercept Error可以為你的服務器建立專屬的錯誤格式,協助你的程式能夠分別錯誤來源。

let packhouse = new Packhouse()
let group = {
    tools: {
        demo: {
            handler(self) {
                self.error('error')
            }
        }
    }
}

packhouse.addGroup('demo', () => {
    return {
        data: group 
    }
})

packhouse.interceptError(error => {
    return {
        error,
        isPackhouse: true
    }
})

packhouse.tool('demo/demo').action(error => {
    console.log(error.error) // error
    console.log(error.isPackhouse) // true
})

PreviousMainNextStep

Last updated 4 years ago

Was this helpful?