mirror of
https://github.com/esiur/esiur-js.git
synced 2026-04-03 21:48:21 +00:00
Rename
This commit is contained in:
@@ -36,7 +36,7 @@ export default class AsyncException extends Error
|
||||
|
||||
raise(type, code, message)
|
||||
{
|
||||
this.type = (type == 0 ? "Management" : "Execusion");
|
||||
this.type = type;
|
||||
this.code = code;
|
||||
|
||||
if (type == 0)
|
||||
@@ -56,6 +56,6 @@ export default class AsyncException extends Error
|
||||
|
||||
toString()
|
||||
{
|
||||
return this.type + " (" + this.code + ") : " + this.message;
|
||||
return (this.type == 0 ? "Management" : "Exception") + " (" + this.code + ") : " + this.message;
|
||||
}
|
||||
}
|
||||
@@ -30,13 +30,21 @@ import AsyncException from './AsyncException.js';
|
||||
|
||||
export default class AsyncReply extends Promise
|
||||
{
|
||||
then(callback)
|
||||
then(callback, onError)
|
||||
{
|
||||
this.callbacks.push(callback);
|
||||
|
||||
if (this.ready)
|
||||
callback(this.result, this);
|
||||
|
||||
if (callback != undefined)
|
||||
{
|
||||
this.callbacks.push(callback);
|
||||
|
||||
if (this.ready)
|
||||
callback(this.result, this);
|
||||
}
|
||||
|
||||
if (onError != undefined)
|
||||
{
|
||||
this.error(onError);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -46,11 +54,6 @@ export default class AsyncReply extends Promise
|
||||
this.then(callback);
|
||||
}
|
||||
|
||||
// Alias for error()
|
||||
catch(callback)
|
||||
{
|
||||
return this.error(callback);
|
||||
}
|
||||
|
||||
error(callback)
|
||||
{
|
||||
@@ -103,7 +106,7 @@ export default class AsyncReply extends Promise
|
||||
this.exception.raise(type, code, message);
|
||||
|
||||
if (this.errorCallbacks.length == 0)
|
||||
throw this.exception;
|
||||
throw this.exception;
|
||||
else
|
||||
for(var i = 0; i < this.errorCallbacks.length; i++)
|
||||
this.errorCallbacks[i](this.exception, this);
|
||||
|
||||
Reference in New Issue
Block a user