@@ -222,7 +222,8 @@ export default Ember.Object.extend(Ember.Evented, {
222222 } ) ;
223223 }
224224 } ) . catch ( function ( error ) {
225- reject ( new FetchError ( 'Unable to Fetch resource(s)' , error ) ) ;
225+ let msg = ( error && error . message ) ? error . message : 'Unable to Fetch resource(s)' ;
226+ reject ( new FetchError ( msg , error ) ) ;
226227 } ) ;
227228 } ) ;
228229 } ,
@@ -324,25 +325,29 @@ export default Ember.Object.extend(Ember.Evented, {
324325} ) ;
325326
326327function ServerError ( message = 'Server Error' , response = null ) {
327- this . name = 'Server Error ' ;
328+ this . name = 'ServerError ' ;
328329 this . message = message ;
329330 this . response = response ;
331+ this . errors = response . errors || null ;
330332}
331333ServerError . prototype = Object . create ( Error . prototype ) ;
332334ServerError . prototype . constructor = ServerError ;
333335
334- function ClientError ( message = 'API Error' , response = null ) {
335- this . name = 'API Error ' ;
336+ function ClientError ( message = 'Client Error' , response = null ) {
337+ this . name = 'ClientError ' ;
336338 this . message = message ;
337339 this . response = response ;
338- this . errors = response . errors ;
340+ this . errors = response . errors || null ;
341+ this . errors = ( response ) ? response . errors || null : null ;
339342}
340343ClientError . prototype = Object . create ( Error . prototype ) ;
341344ClientError . prototype . constructor = ClientError ;
342345
343346function FetchError ( message = 'Fetch Error' , error = null , response = null ) {
344- this . name = 'Fetch Error ' ;
347+ this . name = 'FetchError ' ;
345348 this . message = message ;
349+ this . stack = ( error ) ? error . stack || null : null ;
350+
346351 this . error = error ;
347352 this . response = response ;
348353}
0 commit comments