# Class Exception

Class
Module
import { Exception } from "@tsed/exceptions"
Source/packages/exceptions/src/core/Exception.ts

# Overview

class Exception extends Error {
name<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>

message<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>

type<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>

stack<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>
origin<span class="token punctuation">:</span> Error & <span class="token keyword">any</span><span class="token punctuation">;</span>

status<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">;</span>

body<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

headers<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token punctuation">[</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token keyword">constructor</span><span class="token punctuation">(</span>status?<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">,</span> message?<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> origin?<span class="token punctuation">:</span> Error | <span class="token keyword">string</span> | <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">setHeaders</span><span class="token punctuation">(</span>headers<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">setHeader</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">setOrigin</span><span class="token punctuation">(</span>origin<span class="token punctuation">:</span> Error | <span class="token keyword">string</span> | <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>
<span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>

}

# Members

name: string;

Exception base name


message: string;

Message of the exception


type: string;

Exception type


stack: string;

Stack calling


origin: Error & any;

status: number;

HTTP Code Status


body: any;

headers: {
     [key: string]: any;
 };

Headers must be sent to the response


[key: string]: any;

setHeaders(headers: {
     [key: string]: any;
 }): this;

setHeader(key: string, value: any): this;

setOrigin(origin: Error | string | any): void;

toString(): string;

Other topics